]> jfr.im git - munin-plugins.git/blame - snmp__if_err_
support for a 2nd unbound plugin
[munin-plugins.git] / snmp__if_err_
CommitLineData
3decc5d1
JR
1#!/usr/bin/perl -w
2# -*- cperl -*-
3
4=head1 NAME
5
6snmp__if_err_ - SNMP wildcard plugin to monitor errors on network interfaces of any networked equipment.
7
8=head1 APPLICABLE SYSTEMS
9
10Any SNMP capable networked computer equipment. Using a command such
11as "munin-node-configure --snmp switch.langfeldt.net --snmpversion 2c
12--snmpcommunity public | sh -x" should auto-detect all applicable
13interfaces. On a typical switch you will get one plugin pr. ethernet
14port. On a router you might get one plugin pr. VLAN interface.
15
16=head1 CONFIGURATION
17
18As a rule SNMP plugins need site specific configuration. The default
19configuration (shown here) will only work on insecure sites/devices:
20
21 [snmp_*]
22 env.version 2
23 env.community public
24
25In general SNMP is not very secure at all unless you use SNMP version
263 which supports authentication and privacy (encryption). But in any
27case the community string for your devices should not be "public".
28
29Please see 'perldoc Munin::Plugin::SNMP' for further configuration
30information.
31
32=head1 INTERPRETATION
33
34The graph shows a stright forward gauge of errors per second. This
35graph sums all different kinds of interface errors.
36
37=head1 MIB INFORMATION
38
39The pluguin requires the IF-MIB, the standard IETF MIB for network
40interfaces. It sums these OIDs: IF-MIB::ifInDiscards,
41IF-MIB::ifInErrors, IF-MIB::ifInUnknownProtos, IF-MIB::ifOutDiscards
42and 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
55None known.
56
57Earlier versions of this plugin only reported the ifInErrors and
58ifOutErrors numbers. This does not encompas all errors on a interface
59therefore the change.
60
61=head1 AUTHOR
62
63Copyright (C) 2004-2009. Original authors Jimmy Olsen, Dagfinn Ilmari
64Mannsaaker. Porting to Munin::Plugin::SNMP, documentation, grooming
65and updates by Nicolai Langfeldt
66
67=head1 LICENSE
68
69GPLv2
70
71=cut
72
73use strict;
74use Munin::Plugin;
75use Munin::Plugin::SNMP;
76
77
78my $response;
79
80if (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
86my ($host) = Munin::Plugin::SNMP->config_session();
87
88my $iface;
89
90if ($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
96my $ifEntryDescr = "1.3.6.1.2.1.2.2.1.2.$iface";
97my $ifEntryAlias = "1.3.6.1.2.1.31.1.1.1.18.$iface";
98
99my $ifStatus = "1.3.6.1.2.1.2.2.1.8.$iface";
100
101my $ifInDiscards = "1.3.6.1.2.1.2.2.1.13.$iface";
102my $ifInErrors = "1.3.6.1.2.1.2.2.1.14.$iface";
103my $ifInUnknownProtos= "1.3.6.1.2.1.2.2.1.15.$iface";
104my $ifOutDiscards = "1.3.6.1.2.1.2.2.1.19.$iface";
105my $ifOutErrors = "1.3.6.1.2.1.2.2.1.20.$iface";
106
107my $session = Munin::Plugin::SNMP->session();
108
109if ($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
155if (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
163my $recv = ($session->get_single($ifInErrors) || 0) +
164 ($session->get_single($ifInDiscards) || 0) +
165 ($session->get_single($ifInUnknownProtos) || 0);
166
167my $send = ($session->get_single($ifOutErrors) || 0) +
168 ($session->get_single($ifOutDiscards) || 0);
169
170print "recv.value ", $recv, "\n";
171print "send.value ", $send, "\n";