mirror of
https://github.com/pstadler/metrics.sh.git
synced 2025-02-28 13:59:12 -05:00
minor code cleanup
This commit is contained in:
parent
916cabc8ec
commit
9312c27c9c
@ -8,12 +8,12 @@ if [ -z $NETWORK_IO_INTERFACE ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
declare -r __network_io_divisor=$(($INTERVAL*1024))
|
||||
declare -r __network_io_divisor=$[$INTERVAL * 1024]
|
||||
__network_io_sample=(0 0)
|
||||
|
||||
__network_io_calc_kBps() {
|
||||
echo $1 $2 | awk -v divisor=$__network_io_divisor \
|
||||
'{printf "%.2f", ($1 - $2) / divisor}'
|
||||
'{printf "%.2f", ($1 - $2) / divisor}'
|
||||
}
|
||||
|
||||
if is_osx; then
|
||||
@ -23,7 +23,8 @@ if is_osx; then
|
||||
}
|
||||
else
|
||||
__network_io_collect () {
|
||||
echo TODO
|
||||
cat /proc/net/dev | awk -v iface_regex="$NETWORK_IO_INTERFACE:" \
|
||||
'$0 ~ iface_regex {print $2" "$10}'
|
||||
}
|
||||
fi
|
||||
|
||||
@ -38,4 +39,5 @@ collect () {
|
||||
|
||||
docs () {
|
||||
echo "Network traffic in kB/s."
|
||||
echo "\$NETWORK_IO_INTERFACE=$NETWORK_IO_INTERFACE"
|
||||
}
|
@ -56,6 +56,18 @@ for metric in ${__METRICS[@]}; do
|
||||
echo
|
||||
done
|
||||
|
||||
report () {
|
||||
local result
|
||||
if [ -z $2 ]; then
|
||||
label=$metric
|
||||
result="$1"
|
||||
else
|
||||
label="$metric.$1"
|
||||
result="$2"
|
||||
fi
|
||||
__r_${REPORTER}_report $label $result
|
||||
}
|
||||
|
||||
# collect metrics
|
||||
while true; do
|
||||
for metric in ${__METRICS[@]}; do
|
||||
@ -63,18 +75,6 @@ while true; do
|
||||
continue
|
||||
fi
|
||||
|
||||
report () {
|
||||
local result
|
||||
if [ -z $2 ]; then
|
||||
label=$metric
|
||||
result="$1"
|
||||
else
|
||||
label="$metric.$1"
|
||||
result="$2"
|
||||
fi
|
||||
__r_${REPORTER}_report $label $result
|
||||
}
|
||||
|
||||
__m_${metric}_collect
|
||||
done
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user