3
# $Log: snmp__if_err_.in,v $
4
# Revision 1.2 2004/04/30 22:20:22 jimmyo
5
# It should now even work. :-)
7
# Revision 1.1 2004/04/30 16:59:45 jimmyo
8
# New SNMP plugin: if_err
10
# Revision 1.3 2004/02/22 20:17:58 jimmyo
13
# Revision 1.2 2004/02/18 21:54:56 jimmyo
14
# Did a bit of work on the snmp-thingie.
16
# Revision 1.1 2004/01/02 18:50:00 jimmyo
17
# Renamed occurrances of lrrd -> munin
19
# Revision 1.1.1.1 2004/01/02 15:18:07 jimmyo
20
# Import of LRRD CVS tree after renaming to Munin
22
# Revision 1.1 2003/12/19 20:53:45 jimmyo
32
my $host = $ENV{host} || undef;
33
my $port = $ENV{port} || 161;
34
my $community = $ENV{community} || "public";
35
my $iface = $ENV{interface} || undef;
39
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
41
print "number 1.3.6.1.2.1.2.1.0\n";
42
print "index 1.3.6.1.2.1.2.2.1.1.\n";
43
print "require 1.3.6.1.2.1.2.2.1.3. ^6\$\n"; # Type
44
print "require 1.3.6.1.2.1.2.2.1.5. [1-9]\n"; # Speed
48
if ($0 =~ /^(?:|.*\/)snmp_([^_]+)_if_err_(.+)$/)
52
if ($host =~ /^([^:]+):(\d+)$/)
60
print "# Debug: $0 -- $1 -- $2\n" if $DEBUG;
61
die "# Error: couldn't understand what I'm supposed to monitor.";
64
my $ifEntryDescr = "1.3.6.1.2.1.2.2.1.2.$iface";
65
my $ifEntrySpeed = "1.3.6.1.2.1.2.2.1.5.$iface";
66
my $ifEntryStatus = "1.3.6.1.2.1.2.2.1.8.$iface";
67
my $ifEntryInErrors = "1.3.6.1.2.1.2.2.1.14.$iface";
68
my $ifEntryOutErrors = "1.3.6.1.2.1.2.2.1.20.$iface";
70
my ($session, $error) = Net::SNMP->session(
72
-community => $community,
76
if (!defined ($session))
78
die "Croaking: $error";
81
if ($ARGV[0] and $ARGV[0] eq "config")
83
print "host_name $host\n";
84
if (!defined ($response = $session->get_request($ifEntryDescr)))
86
die "Croaking: " . $session->error();
88
my $name = $response->{$ifEntryDescr};
90
if (defined ($response = $session->get_request($ifEntrySpeed)))
92
$warn = $response->{$ifEntrySpeed}/8;
94
print "graph_title $name errors\n";
95
print "graph_order recv send\n";
96
print "graph_args --base 1000\n";
97
print "graph_vlabel bps in (-) / out (+)\n";
98
print "recv.label recv\n";
99
print "recv.type COUNTER\n";
100
print "recv.graph no\n";
101
print "recv.cdef recv,8,*\n";
102
print "recv.max 2000000000\n";
103
print "recv.warn ", (-$warn), "\n" if defined $warn;
104
print "send.label bps\n";
105
print "send.type COUNTER\n";
106
print "send.negative recv\n";
107
print "send.cdef send,8,*\n";
108
print "send.max 2000000000\n";
109
print "send.warn $warn\n" if defined $warn;
114
if (defined ($response = $session->get_request($ifEntryStatus)))
116
$status = $response->{$ifEntryStatus};
121
print "recv.value U\n";
122
print "send.value U\n";
126
if (defined ($response = $session->get_request($ifEntryInErrors)))
128
print "recv.value ", $response->{$ifEntryInErrors}, "\n";
132
print "recv.value U\n";
135
if (defined ($response = $session->get_request($ifEntryOutErrors)))
137
print "send.value ", $response->{$ifEntryOutErrors}, "\n";
141
print "send.value U\n";