diff --git a/metrics/network_io.sh b/metrics/network_io.sh index 59c7190..f45e695 100644 --- a/metrics/network_io.sh +++ b/metrics/network_io.sh @@ -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" } \ No newline at end of file diff --git a/sysmetricsd.sh b/sysmetricsd.sh index 4ee847a..84ff1cc 100755 --- a/sysmetricsd.sh +++ b/sysmetricsd.sh @@ -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