forked from munin-monitoring/munin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnmp__if_err_
executable file
·166 lines (120 loc) · 4.65 KB
/
snmp__if_err_
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/usr/bin/perl -w
=head1 NAME
snmp__if_err_ - SNMP wildcard plugin to monitor errors on network interfaces of any networked equipment.
=head1 APPLICABLE SYSTEMS
Any SNMP capable networked computer equipment. Using a command such
as "munin-node-configure --snmp switch.langfeldt.net --snmpversion 2c
--snmpcommunity public | sh -x" should auto-detect all applicable
interfaces. On a typical switch you will get one plugin pr. ethernet
port. On a router you might get one plugin pr. VLAN interface.
=head1 CONFIGURATION
As a rule SNMP plugins need site specific configuration. The default
configuration (shown here) will only work on insecure sites/devices:
[snmp_*]
env.version 2
env.community public
In general SNMP is not very secure at all unless you use SNMP version
3 which supports authentication and privacy (encryption). But in any
case the community string for your devices should not be "public".
Please see 'perldoc Munin::Plugin::SNMP' for further configuration
information.
=head1 INTERPRETATION
The graph shows a stright forward gauge of errors per second. This
graph sums all different kinds of interface errors.
=head1 MIB INFORMATION
The pluguin requires the IF-MIB, the standard IETF MIB for network
interfaces. It sums these OIDs: IF-MIB::ifInDiscards,
IF-MIB::ifInErrors, IF-MIB::ifInUnknownProtos, IF-MIB::ifOutDiscards
and IF-MIB::ifOutErrors.
=head1 MAGIC MARKERS
#%# family=snmpauto
#%# capabilities=snmpconf
=head1 BUGS
None known.
Earlier versions of this plugin only reported the ifInErrors and
ifOutErrors numbers. This does not encompas all errors on a interface
therefore the change.
=head1 AUTHOR
Copyright (C) 2004-2009. Original authors Jimmy Olsen, Dagfinn Ilmari
Mannsaaker. Porting to Munin::Plugin::SNMP, documentation, grooming
and updates by Nicolai Langfeldt
=head1 LICENSE
GPLv2
=cut
use strict;
use Munin::Plugin;
use Munin::Plugin::SNMP;
my $response;
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf") {
print "index 1.3.6.1.2.1.2.2.1.1.\n";
print "require 1.3.6.1.2.1.2.2.1.10. [1-9]\n"; # ifInOctets
exit 0;
}
my ($host) = Munin::Plugin::SNMP->config_session();
my $iface;
if ($Munin::Plugin::me =~ /if_err_(\d+)$/) {
$iface = $1;
} else {
die "Could not determine interface number from ".$Munin::Plugin::me."\n";
}
my $ifEntryDescr = "1.3.6.1.2.1.2.2.1.2.$iface";
my $ifEntryAlias = "1.3.6.1.2.1.31.1.1.1.18.$iface";
my $ifStatus = "1.3.6.1.2.1.2.2.1.8.$iface";
my $ifInDiscards = "1.3.6.1.2.1.2.2.1.13.$iface";
my $ifInErrors = "1.3.6.1.2.1.2.2.1.14.$iface";
my $ifInUnknownProtos= "1.3.6.1.2.1.2.2.1.15.$iface";
my $ifOutDiscards = "1.3.6.1.2.1.2.2.1.19.$iface";
my $ifOutErrors = "1.3.6.1.2.1.2.2.1.20.$iface";
my $session = Munin::Plugin::SNMP->session();
if ($ARGV[0] and $ARGV[0] eq "config") {
my ($host) = Munin::Plugin::SNMP->config_session();
print "host_name $host\n" unless $host eq 'localhost';
my $alias = $session->get_single($ifEntryAlias) ||
$session->get_single($ifEntryDescr) ||
"Interface $iface";
if (! ($alias =~ /\d+/) ) {
# If there are no numbers in the $alias add the if index
$alias .=" (if $iface)";
}
my $extrainfo = '';
if (defined ($response = $session->get_single($ifStatus))) {
if ($response == 2) {
# Interface is down
$extrainfo .= ' The interface is currently down.'
}
}
# Any error is too many
my $warn = 1;
print "graph_title Interface $alias errors\n";
print "graph_order recv send\n";
print "graph_args --base 1000\n";
print "graph_vlabel Errors in (-) / out (+) per \${graph_period}\n";
print "graph_category network\n";
print "graph_info This graph shows all kinds of errors for the \"$alias\" network interface.$extrainfo\n";
print "send.info Number of unsuccessful send/receive operations (errors) on this interface.\n";
print "recv.label recv\n";
print "recv.type DERIVE\n";
print "recv.graph no\n";
print "recv.min 0\n";
print "recv.warning ", ($warn), "\n" if defined $warn;
print "send.label errors\n";
print "send.type DERIVE\n";
print "send.negative recv\n";
print "send.min 0\n";
print "send.warning $warn\n" if defined $warn;
exit 0;
}
if (defined ($response = $session->get_single($ifStatus))) {
if ($response == 2) {
print "recv.value U\n";
print "send.value U\n";
exit 0;
}
}
my $recv = ($session->get_single($ifInErrors) || 0) +
($session->get_single($ifInDiscards) || 0) +
($session->get_single($ifInUnknownProtos) || 0);
my $send = ($session->get_single($ifOutErrors) || 0) +
($session->get_single($ifOutDiscards) || 0);
print "recv.value ", $recv, "\n";
print "send.value ", $send, "\n";