From 0469046f7f89184e7f42457568f5df1b449fecb8 Mon Sep 17 00:00:00 2001 From: Alexey Illarionov Date: Wed, 17 Nov 2010 23:48:45 +0100 Subject: [PATCH] Initial version --- plugins/other/ifem_ | 81 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100755 plugins/other/ifem_ diff --git a/plugins/other/ifem_ b/plugins/other/ifem_ new file mode 100755 index 00000000..63d4d522 --- /dev/null +++ b/plugins/other/ifem_ @@ -0,0 +1,81 @@ +#!/bin/sh +# +# Wildcard-plugin to monitor FreeBSD em(4) and igb(4) network interfaces +# using sysctl dev.em.0.mac_stats 64-bit counters +# To monitor an # interface, link if_ to this file. E.g. +# +# ln -s /usr/share/munin/node/plugins-auto/if_ /etc/munin/node.d/if_em0 +# +# ...will monitor em0. +# +# Magic markers (optional - used by munin-config and some installation +# scripts): +# +#%# family=auto +#%# capabilities=autoconf suggest + + +INTERFACE=`basename $0 | sed 's/^ifem_//g'` + +if [ "$1" = "autoconf" ]; then + if [ -x /sbin/sysctl ]; then + echo yes + exit 0 + else + echo "no (/sbin/sysctl not found)" + exit 0 + fi +fi + +if [ "$1" = "suggest" ]; then + if [ -x /sbin/sysctl ]; then + /sbin/sysctl -q dev.em dev.igb | /usr/bin/awk -F '.' '/mac_stats\.total_pkts_recvd/{print $2$3;}' + exit 0 + else + exit 1 + fi +fi + +if [ "$1" = "config" ]; then + + echo "graph_order rbytes obytes" + echo "graph_title $INTERFACE traffic" + echo 'graph_args --base 1000' + echo 'graph_vlabel bits per ${graph_period} in (-) / out (+)' + echo 'graph_category network' + echo "graph_info This graph shows the traffic of the $INTERFACE network interface. Please note that the traffic is shown in bits per second, not bytes." + echo 'rbytes.label received' + echo 'rbytes.type COUNTER' + echo 'rbytes.graph no' + echo 'rbytes.cdef rbytes,8,*' + echo 'obytes.label bps' + echo 'obytes.type COUNTER' + echo 'obytes.negative rbytes' + echo 'obytes.cdef obytes,8,*' + echo "obytes.info Traffic sent (+) and received (-) on the $INTERFACE network interface." + exit 0 +fi + +oid=`echo $INTERFACE | sed -E 's/^(em|igb)([0-9]+)$/dev\.\1\.\2\.mac_stats/g'` +rbytes='U' +obytes='U' + +while read ev val; do + case "$ev" in + "$oid.good_octets_recvd:") + rbytes="$val" + ;; + "$oid.good_octets_txd:") + obytes="$val" + ;; + "$oid.good_octest_txd:") + obytes="$val" + ;; + esac +done << EOF +$(/sbin/sysctl -q $oid 2>/dev/null) +EOF + +printf "rbytes.value ${rbytes}\nobytes.value ${obytes}\n" + +