2
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00
contrib-munin/plugins/network/if1sec_

64 lines
1.5 KiB
Text
Raw Normal View History

2013-02-03 21:34:36 +01:00
#! /bin/sh
# Currently the plugin does *not* autostart
#
# It has to be launched via rc.d :
# munin-run if1sec_eth0 acquire
2013-02-03 21:34:36 +01:00
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
2013-02-04 10:18:40 +01:00
if [ ! -r "/sys/class/net/$IFACE/statistics/tx_bytes" ]
then
echo "# Unknown Interface : $IFACE"
exit 1
fi
2013-02-03 21:34:36 +01:00
if [ "$1" = "acquire" ]
then
2013-02-04 10:18:40 +01:00
(
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;
system(\"\");
2013-02-04 10:18:40 +01:00
}" >> $cache
) &
2013-02-03 21:34:36 +01:00
echo $! > $pidfile
2013-02-04 10:18:40 +01:00
exit 0
2013-02-03 21:34:36 +01:00
fi
if [ "$1" = "config" ]
then
2013-02-04 10:18:40 +01:00
cat <<EOF
2013-02-03 21:34:36 +01:00
graph_title Interface 1sec stats for ${IFACE}
graph_category 1sec::network
graph_data_size custom 1d, 10s for 1w, 1m for 1t, 5m for 1y
2013-02-04 10:52:02 +01:00
graph_vlabel Bytes
2013-02-03 21:34:36 +01:00
update_rate 1
2013-02-04 10:52:02 +01:00
${IFACE}_tx.label ${IFACE} TX bytes
2013-02-04 10:18:40 +01:00
${IFACE}_tx.type DERIVE
${IFACE}_tx.min 0
2013-02-04 10:52:02 +01:00
${IFACE}_rx.label ${IFACE} RX bytes
2013-02-04 10:18:40 +01:00
${IFACE}_rx.type DERIVE
${IFACE}_rx.min 0
2013-02-03 21:34:36 +01:00
EOF
2013-02-04 10:18:40 +01:00
exit 0
2013-02-03 21:34:36 +01:00
fi
# values
2013-02-04 10:18:40 +01:00
cat ${cache}
> ${cache}
2013-02-03 21:34:36 +01:00
exit 0