1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-29 20:34:51 +00:00

if1sec: fixes

This commit is contained in:
Steve Schnepp 2013-02-04 10:18:40 +01:00
parent 208874d74d
commit 63d61bc52e

View file

@ -7,38 +7,49 @@ cache="$MUNIN_PLUGSTATE/munin.$plugin.value"
IFACE="${0##*/if1sec_}" # interface IFACE="${0##*/if1sec_}" # interface
if [ ! -r "/sys/class/net/$IFACE/statistics/tx_bytes" ]
then
echo "# Unknown Interface : $IFACE"
exit 1
fi
if [ "$1" = "acquire" ] if [ "$1" = "acquire" ]
then then
while sleep 1 (
do while sleep 1
echo $( do
date +%s echo $(
cat /sys/class/net/$IFACE/statistics/tx_bytes date +%s
cat /sys/class/net/$IFACE/statistics/rx_bytes cat /sys/class/net/$IFACE/statistics/tx_bytes
) cat /sys/class/net/$IFACE/statistics/rx_bytes
done | awk "{ )
print \"${IFACE}_tx.value \" \$1 \":\" \$2; done | awk "{
print \"${IFACE}_rx.value \" \$1 \":\" \$3; print \"${IFACE}_tx.value \" \$1 \":\" \$2;
}" >> $cache & print \"${IFACE}_rx.value \" \$1 \":\" \$3;
}" >> $cache
) &
echo $! > $pidfile echo $! > $pidfile
exit 0 exit 0
fi fi
if [ "$1" = "config" ] if [ "$1" = "config" ]
then then
cat <<EOF cat <<EOF
graph_title Interface 1sec stats for ${IFACE} graph_title Interface 1sec stats for ${IFACE}
graph_category 1sec::network graph_category 1sec::network
graph_data_size custom 1d, 10s for 1w, 1m for 1t, 5m for 1y graph_data_size custom 1d, 10s for 1w, 1m for 1t, 5m for 1y
update_rate 1 update_rate 1
${IFACE}_tx.type DERIVE
${IFACE}_tx.min 0
${IFACE}_rx.type DERIVE
${IFACE}_rx.min 0
EOF EOF
exit 0 exit 0
fi fi
# values # values
cat ${FILE_VALUES} cat ${cache}
> ${FILE_VALUES} > ${cache}
exit 0 exit 0