#! /bin/sh pluginfull="$0" # full name of plugin plugin="${0##*/}" # name of plugin pidfile="$MUNIN_PLUGSTATE/munin.$plugin.pid" 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 ( exec <&- >&- 2>&- while sleep 1 do read tx < /sys/class/net/$IFACE/statistics/tx_bytes read rx < /sys/class/net/$IFACE/statistics/rx_bytes echo "$tx $rx" done | awk "{ now = systime() print \"${IFACE}_tx.value \" now \":\" \$1 print \"${IFACE}_rx.value \" now \":\" \$2 system(\"\") }" >> $cache ) & echo $! > $pidfile exit 0 fi if [ "$1" = "config" ] then cat < ${cache} exit 0