]>
Commit | Line | Data |
---|---|---|
3decc5d1 JR |
1 | #!/usr/bin/perl -w |
2 | # -*- cperl -*- | |
3 | ||
4 | =head1 NAME | |
5 | ||
6 | snmp__if_err_ - SNMP wildcard plugin to monitor errors on network interfaces of any networked equipment. | |
7 | ||
8 | =head1 APPLICABLE SYSTEMS | |
9 | ||
10 | Any SNMP capable networked computer equipment. Using a command such | |
11 | as "munin-node-configure --snmp switch.langfeldt.net --snmpversion 2c | |
12 | --snmpcommunity public | sh -x" should auto-detect all applicable | |
13 | interfaces. On a typical switch you will get one plugin pr. ethernet | |
14 | port. On a router you might get one plugin pr. VLAN interface. | |
15 | ||
16 | =head1 CONFIGURATION | |
17 | ||
18 | As a rule SNMP plugins need site specific configuration. The default | |
19 | configuration (shown here) will only work on insecure sites/devices: | |
20 | ||
21 | [snmp_*] | |
22 | env.version 2 | |
23 | env.community public | |
24 | ||
25 | In general SNMP is not very secure at all unless you use SNMP version | |
26 | 3 which supports authentication and privacy (encryption). But in any | |
27 | case the community string for your devices should not be "public". | |
28 | ||
29 | Please see 'perldoc Munin::Plugin::SNMP' for further configuration | |
30 | information. | |
31 | ||
32 | =head1 INTERPRETATION | |
33 | ||
34 | The graph shows a stright forward gauge of errors per second. This | |
35 | graph sums all different kinds of interface errors. | |
36 | ||
37 | =head1 MIB INFORMATION | |
38 | ||
39 | The pluguin requires the IF-MIB, the standard IETF MIB for network | |
40 | interfaces. It sums these OIDs: IF-MIB::ifInDiscards, | |
41 | IF-MIB::ifInErrors, IF-MIB::ifInUnknownProtos, IF-MIB::ifOutDiscards | |
42 | and IF-MIB::ifOutErrors. | |
43 | ||
44 | =head1 MAGIC MARKERS | |
45 | ||
46 | #%# family=snmpauto | |
47 | #%# capabilities=snmpconf | |
48 | ||
49 | =head1 VERSION | |
50 | ||
51 | $Id$ | |
52 | ||
53 | =head1 BUGS | |
54 | ||
55 | None known. | |
56 | ||
57 | Earlier versions of this plugin only reported the ifInErrors and | |
58 | ifOutErrors numbers. This does not encompas all errors on a interface | |
59 | therefore the change. | |
60 | ||
61 | =head1 AUTHOR | |
62 | ||
63 | Copyright (C) 2004-2009. Original authors Jimmy Olsen, Dagfinn Ilmari | |
64 | Mannsaaker. Porting to Munin::Plugin::SNMP, documentation, grooming | |
65 | and updates by Nicolai Langfeldt | |
66 | ||
67 | =head1 LICENSE | |
68 | ||
69 | GPLv2 | |
70 | ||
71 | =cut | |
72 | ||
73 | use strict; | |
74 | use Munin::Plugin; | |
75 | use Munin::Plugin::SNMP; | |
76 | ||
77 | ||
78 | my $response; | |
79 | ||
80 | if (defined $ARGV[0] and $ARGV[0] eq "snmpconf") { | |
81 | print "index 1.3.6.1.2.1.2.2.1.1.\n"; | |
82 | print "require 1.3.6.1.2.1.2.2.1.10. [1-9]\n"; # ifInOctets | |
83 | exit 0; | |
84 | } | |
85 | ||
86 | my ($host) = Munin::Plugin::SNMP->config_session(); | |
87 | ||
88 | my $iface; | |
89 | ||
90 | if ($Munin::Plugin::me =~ /if_err_(\d+)$/) { | |
91 | $iface = $1; | |
92 | } else { | |
93 | die "Could not determine interface number from ".$Munin::Plugin::me."\n"; | |
94 | } | |
95 | ||
96 | my $ifEntryDescr = "1.3.6.1.2.1.2.2.1.2.$iface"; | |
97 | my $ifEntryAlias = "1.3.6.1.2.1.31.1.1.1.18.$iface"; | |
98 | ||
99 | my $ifStatus = "1.3.6.1.2.1.2.2.1.8.$iface"; | |
100 | ||
101 | my $ifInDiscards = "1.3.6.1.2.1.2.2.1.13.$iface"; | |
102 | my $ifInErrors = "1.3.6.1.2.1.2.2.1.14.$iface"; | |
103 | my $ifInUnknownProtos= "1.3.6.1.2.1.2.2.1.15.$iface"; | |
104 | my $ifOutDiscards = "1.3.6.1.2.1.2.2.1.19.$iface"; | |
105 | my $ifOutErrors = "1.3.6.1.2.1.2.2.1.20.$iface"; | |
106 | ||
107 | my $session = Munin::Plugin::SNMP->session(); | |
108 | ||
109 | if ($ARGV[0] and $ARGV[0] eq "config") { | |
110 | my ($host) = Munin::Plugin::SNMP->config_session(); | |
111 | ||
112 | print "host_name $host\n" unless $host eq 'localhost'; | |
113 | ||
114 | my $alias = $session->get_single($ifEntryAlias) || | |
115 | $session->get_single($ifEntryDescr) || | |
116 | "Interface $iface"; | |
117 | ||
118 | if (! ($alias =~ /\d+/) ) { | |
119 | # If there are no numbers in the $alias add the if index | |
120 | $alias .=" (if $iface)"; | |
121 | } | |
122 | ||
123 | my $extrainfo = ''; | |
124 | ||
125 | if (defined ($response = $session->get_single($ifStatus))) { | |
126 | if ($response == 2) { | |
127 | # Interface is down | |
128 | $extrainfo .= ' The interface is currently down.' | |
129 | } | |
130 | } | |
131 | ||
132 | # Any error is too many | |
133 | my $warn = 1; | |
134 | ||
135 | print "graph_title Interface $alias errors\n"; | |
136 | print "graph_order recv send\n"; | |
137 | print "graph_args --base 1000 --logarithmic\n"; | |
138 | print "graph_vlabel Errors in (-) / out (+) per \${graph_period}\n"; | |
139 | print "graph_category network\n"; | |
140 | print "graph_info This graph shows all kinds of errors for the \"$alias\" network interface.$extrainfo\n"; | |
141 | print "send.info Number of unsuccessfull send/receive operations (errors) on this interface.\n"; | |
142 | print "recv.label recv\n"; | |
143 | print "recv.type DERIVE\n"; | |
144 | print "recv.graph no\n"; | |
145 | print "recv.min 0\n"; | |
146 | print "recv.warning ", ($warn), "\n" if defined $warn; | |
147 | print "send.label errors\n"; | |
148 | print "send.type DERIVE\n"; | |
149 | print "send.negative recv\n"; | |
150 | print "send.min 0\n"; | |
151 | print "send.warning $warn\n" if defined $warn; | |
152 | exit 0; | |
153 | } | |
154 | ||
155 | if (defined ($response = $session->get_single($ifStatus))) { | |
156 | if ($response == 2) { | |
157 | print "recv.value U\n"; | |
158 | print "send.value U\n"; | |
159 | exit 0; | |
160 | } | |
161 | } | |
162 | ||
163 | my $recv = ($session->get_single($ifInErrors) || 0) + | |
164 | ($session->get_single($ifInDiscards) || 0) + | |
165 | ($session->get_single($ifInUnknownProtos) || 0); | |
166 | ||
167 | my $send = ($session->get_single($ifOutErrors) || 0) + | |
168 | ($session->get_single($ifOutDiscards) || 0); | |
169 | ||
170 | print "recv.value ", $recv, "\n"; | |
171 | print "send.value ", $send, "\n"; |