~ubuntu-branches/ubuntu/gutsy/munin/gutsy

« back to all changes in this revision

Viewing changes to node/node.d/snmp__fc_if_err_.in

  • Committer: Bazaar Package Importer
  • Author(s): Tore Anderson
  • Date: 2004-05-21 20:51:19 UTC
  • Revision ID: james.westby@ubuntu.com-20040521205119-oz8bllbjp9hs80ig
Tags: upstream-0+1.0.0pre5
ImportĀ upstreamĀ versionĀ 0+1.0.0pre5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl -w
 
2
#
 
3
# $Log: snmp__fc_if_err_.in,v $
 
4
# Revision 1.1  2004/04/30 22:22:07  jimmyo
 
5
# Added to SNMP based fibre-channel plugins: fc_if and fc_if_err.
 
6
#
 
7
# Revision 1.4  2004/04/30 16:58:14  jimmyo
 
8
# Added max.
 
9
#
 
10
# Revision 1.3  2004/02/22 20:17:58  jimmyo
 
11
# Typo fix
 
12
#
 
13
# Revision 1.2  2004/02/18 21:54:56  jimmyo
 
14
# Did a bit of work on the snmp-thingie.
 
15
#
 
16
# Revision 1.1  2004/01/02 18:50:00  jimmyo
 
17
# Renamed occurrances of lrrd -> munin
 
18
#
 
19
# Revision 1.1.1.1  2004/01/02 15:18:07  jimmyo
 
20
# Import of LRRD CVS tree after renaming to Munin
 
21
#
 
22
# Revision 1.1  2003/12/19 20:53:45  jimmyo
 
23
# Created by jo
 
24
#
 
25
#
 
26
 
 
27
use strict;
 
28
use Net::SNMP;
 
29
 
 
30
my $DEBUG = 1;
 
31
 
 
32
my $host      = $ENV{host}      || undef;
 
33
my $port      = $ENV{port}      || 161;
 
34
my $community = $ENV{community} || "public";
 
35
my $iface     = $ENV{interface} || undef;
 
36
 
 
37
my $response;
 
38
 
 
39
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
 
40
{
 
41
        print "number  1.3.6.1.2.1.8888.1.1.3.1.4.16.0.8.0.136.3.52.64.0.0.0.0.0.0.0.0\n";
 
42
        print "index   1.3.6.1.2.1.8888.1.1.6.1.1.16.0.8.0.136.3.52.64.0.0.0.0.0.0.0.0.\n";
 
43
        print "require 1.3.6.1.2.1.8888.1.1.6.1.5.16.0.8.0.136.3.52.64.0.0.0.0.0.0.0.0. ^2\$\n"; # state = online
 
44
        print "require 1.3.6.1.2.1.8888.1.1.6.1.14.16.0.8.0.136.3.52.64.0.0.0.0.0.0.0.0. [1-9]\n"; # Speed
 
45
        exit 0;
 
46
}
 
47
 
 
48
if ($0 =~ /^(?:|.*\/)snmp_([^_]+)_fc_if_err_(.+)$/)
 
49
{
 
50
        $host  = $1;
 
51
        $iface = $2;
 
52
        if ($host =~ /^([^:]+):(\d+)$/)
 
53
        {
 
54
                $host = $1;
 
55
                $port = $2;
 
56
        }
 
57
}
 
58
else
 
59
{
 
60
        print "# Debug: $0 -- $1 -- $2\n" if $DEBUG;
 
61
        die "# Error: couldn't understand what I'm supposed to monitor.";
 
62
}
 
63
 
 
64
my $fcEntryDescr     = "1.3.6.1.2.1.8888.1.1.6.1.16.16.0.8.0.136.3.52.64.0.0.0.0.0.0.0.0.$iface"; 
 
65
my $fcEntrySpeed     = "1.3.6.1.2.1.8888.1.1.6.1.14.16.0.8.0.136.3.52.64.0.0.0.0.0.0.0.0.$iface";
 
66
my $fcEntryStatus    = "1.3.6.1.2.1.8888.1.1.6.1.6.16.0.8.0.136.3.52.64.0.0.0.0.0.0.0.0.$iface";
 
67
my $fcEntryErrs      = "1.3.6.1.2.1.8888.1.3.1.1.2.16.0.8.0.136.3.52.64.0.0.0.0.0.0.0.0.$iface";
 
68
my $fcPhysPort       = "1.3.6.1.2.1.8888.1.1.6.1.17.16.0.8.0.136.3.52.64.0.0.0.0.0.0.0.0.$iface";
 
69
 
 
70
my ($session, $error) = Net::SNMP->session(
 
71
                -hostname  => $host,
 
72
                -community => $community,
 
73
                -port      => $port,
 
74
                -version   => "2c"
 
75
        );
 
76
 
 
77
if (!defined ($session))
 
78
{
 
79
        die "Croaking: $error";
 
80
}
 
81
 
 
82
if ($ARGV[0] and $ARGV[0] eq "config")
 
83
{
 
84
        print "host_name $host\n";
 
85
        if (!defined ($response = $session->get_request($fcEntryDescr)))
 
86
        {
 
87
                die "Croaking: " . $session->error();
 
88
        }
 
89
        my $name = $response->{$fcEntryDescr};
 
90
        if (defined ($response = $session->get_request($fcPhysPort)))
 
91
        {
 
92
                $name .= " (" . $response->{$fcPhysPort} . ")";
 
93
        }
 
94
        print "graph_title FC $name errors\n";
 
95
        print "graph_order errs\n";
 
96
        print "graph_args --base 1000\n";
 
97
        print "graph_vlabel errors / second\n";
 
98
        print "errs.label errors\n";
 
99
        print "errs.type COUNTER\n";
 
100
        print "errs.max 4000000000\n";
 
101
        exit 0; 
 
102
}
 
103
 
 
104
my $status = 1;
 
105
if (defined ($response = $session->get_request($fcEntryStatus)))
 
106
{
 
107
        $status = $response->{$fcEntryStatus};
 
108
}
 
109
 
 
110
if ($status != 3)
 
111
{
 
112
        print "errs.value U\n";
 
113
        exit 0;
 
114
}
 
115
 
 
116
if (defined ($response = $session->get_request($fcEntryErrs)))
 
117
{
 
118
        print "errs.value ", $response->{$fcEntryErrs}, "\n";
 
119
}
 
120
else
 
121
{
 
122
        print "recv.value U\n";
 
123
}
 
124