Repository
Munin (master)
Last change
2018-12-16
Graph Categories
Family
auto
Capabilities
Keywords
Language
Shell

if_errcoll_

Sadly there is no documentation for this plugin.

#!/bin/sh
#
# Wildcard-plugin to monitor network interfaces. To monitor an
# interface, link if_<interface> to this file. E.g.
#
#    ln -s /usr/share/munin/node/plugins-auto/if_ /etc/munin/node.d/if_eth0
#
# ...will monitor eth0.
#
# Any device found in /usr/bin/netstat can be monitored.
#
# Magic markers (optional - used by munin-config and some installation
# scripts):
#
#%# family=auto
#%# capabilities=autoconf suggest

INTERFACE=${0##*if_errcoll_}

if [ "$1" = "autoconf" ]; then
	if [ -x /sbin/ifconfig -o -x /usr/bin/netstat ]; then
		echo yes
		exit 0
	else
		echo "no (/usr/bin/netstat not found)"
		exit 0
	fi
fi

if [ "$1" = "suggest" ]; then
	if [ -x /sbin/ifconfig ]
	then
		ifconfig -l | sed -Ee 's/[[:<:]](pfsync|faith|pf(log|sync)|lo|plip|carp|enc|fwe)[^ ]*//g' | xargs -n 1 echo
		exit 0
	elif [ -x /usr/bin/netstat ]; then
		netstat -i -b -n | sed -n -e '/^faith/d' -e '/^lo[0-9]/d' -e '/^pf(log|sync)/d' -e '/<Link#[0-9]*>/s/\** .*//p'
		exit 0
	else
		exit 1
	fi
fi

if [ "$1" = "config" ]; then
	echo "graph_order ierrors oerrors collisions"
	echo "graph_title Interface $INTERFACE errors & collisions"
	echo 'graph_args --base 1000'
	echo 'graph_vlabel events / ${graph_period}'
	echo 'graph_category network'
	echo "graph_info This graph shows the amount of errors and collisions on the $INTERFACE network interface."
	echo 'ierrors.label Input Errors'
        echo 'ierrors.type COUNTER'
        echo 'oerrors.label Output Errors'
	echo 'oerrors.type COUNTER'
        echo 'collisions.label Collisions'
	echo 'collisions.type COUNTER'
	exit 0
fi;

/usr/bin/netstat -i -b -n -I $INTERFACE | awk '
/<Link#[0-9]*>/ {
	if (NF == 10) {
		print "ierrors.value", $5;
		print "oerrors.value", $8;
		print "collisions.value", $10;
	} else if (NF == 11) {
		if ($4 ~ /:/) {
			print "ierrors.value", $6;
			print "oerrors.value", $9;
			print "collisions.value", $11;
		} else {
			print "ierrors.value", $5;
			print "oerrors.value", $9;
			print "collisions.value", $11;
		}
	} else { # NF == 12
		print "ierrors.value", $6;
		print "oerrors.value", $10;
		print "collisions.value", $12;
	}
}'