From 63d61bc52e0c6952277537453143940543a397df Mon Sep 17 00:00:00 2001 From: Steve Schnepp Date: Mon, 4 Feb 2013 10:18:40 +0100 Subject: [PATCH] if1sec: fixes --- plugins/network/if1sec_ | 45 +++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/plugins/network/if1sec_ b/plugins/network/if1sec_ index fe07f4a9..a08cd906 100755 --- a/plugins/network/if1sec_ +++ b/plugins/network/if1sec_ @@ -7,38 +7,49 @@ cache="$MUNIN_PLUGSTATE/munin.$plugin.value" IFACE="${0##*/if1sec_}" # interface +if [ ! -r "/sys/class/net/$IFACE/statistics/tx_bytes" ] +then + echo "# Unknown Interface : $IFACE" + exit 1 +fi + if [ "$1" = "acquire" ] then - while sleep 1 - do - echo $( - date +%s - cat /sys/class/net/$IFACE/statistics/tx_bytes - cat /sys/class/net/$IFACE/statistics/rx_bytes - ) - done | awk "{ - print \"${IFACE}_tx.value \" \$1 \":\" \$2; - print \"${IFACE}_rx.value \" \$1 \":\" \$3; - }" >> $cache & + ( + while sleep 1 + do + echo $( + date +%s + cat /sys/class/net/$IFACE/statistics/tx_bytes + cat /sys/class/net/$IFACE/statistics/rx_bytes + ) + done | awk "{ + print \"${IFACE}_tx.value \" \$1 \":\" \$2; + print \"${IFACE}_rx.value \" \$1 \":\" \$3; + }" >> $cache + ) & echo $! > $pidfile - exit 0 + exit 0 fi if [ "$1" = "config" ] then - cat < ${FILE_VALUES} +cat ${cache} +> ${cache} exit 0 -