~ubuntu-branches/ubuntu/maverick/munin/maverick

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!@@GOODSH@@
# -*- sh -*-

: << =cut

=head1 NAME

if_err_ - Wildcard plugin to monitor errors on network interfaces

=head1 CONFIGURATION

=head2 ENVIRONMENT VARIABLES

This plugin does not use environment variables

=head2 WILDCARD PLUGIN

This is a wildcard plugin. To monitor an interface, link
if_<interface> to this file. E.g.

  ln -s /usr/share/munin/plugins-auto/if_err_ \
        /etc/munin/node.d/if_err_eth0

...will monitor eth0.

Any device found in /usr/bin/kstat can be monitored.

=head1 AUTHOR

Unknown author

=head1 LICENSE

Unknown license

=head1 MAGIC MARKERS

 #%# family=auto
 #%# capabilities=autoconf suggest

=cut

. $MUNIN_LIBDIR/plugins/plugin.sh

INTERFACE=${0##*/if_err_}

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

if [ "$1" = "suggest" ]; then
	if [ -x /usr/bin/kstat ]; then
		kstat -m link -p -s '/^ierrors$/' | awk -F: '{ print $3 }'
		exit 0
	else
		exit 1
	fi
fi

if [ "$1" = "config" ]; then

	echo "graph_order ierrors oerrors collisions"
	echo "graph_title $INTERFACE Errors & Collisions"
	echo 'graph_args --base 1000'
	echo 'graph_vlabel events / ${graph_period}'
	echo 'graph_category network'
	echo 'ierrors.label Input Errors'
        echo 'ierrors.type COUNTER'
        echo 'ierrors.max 2000000000'
	print_warning ierrors
	print_critical ierrors
        echo 'oerrors.label Output Errors'
	echo 'oerrors.type COUNTER'
        echo 'oerrors.max 2000000000'
	print_warning oerrors
	print_critical oerrors
        echo 'collisions.label Collisions'
	echo 'collisions.type COUNTER'
        echo 'collisions.max 2000000000'
	print_warning collisions
	print_critical collisions
	exit 0
fi;

kstat -p -n $INTERFACE -m link -s '/^([io]errors|collisions)$/' | awk -F: '
{
	split($4, four, "\t")
	print four[1] ".value", four[2]
}'