File: snmp__fc_if_err_.in

package info (click to toggle)
munin 2.0.76-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,068 kB
  • sloc: perl: 11,684; java: 1,924; sh: 1,632; makefile: 636; javascript: 365; python: 267
file content (125 lines) | stat: -rw-r--r-- 3,544 bytes parent folder | download | duplicates (6)
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
#!@@PERL@@ -w
# -*- perl -*-
#
# Copyright (C) 2004 Jimmy Olsen
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 2 dated June,
# 1991.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#
#%# family=snmpauto
#%# capabilities=snmpconf

use strict;

use Net::SNMP;
use Munin::Plugin::SNMP;


my $host      = $ENV{host}      || undef;
my $port      = $ENV{port}      || 161;
my $community = $ENV{community} || "public";
my $iface     = $ENV{interface} || undef;

my $response;

if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
{
	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";
	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
	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
	exit 0;
}

if ($0 =~ /^(?:|.*\/)snmp_([^_]+)_fc_if_err_(.+)$/)
{
	$host  = $1;
	$iface = $2;
	if ($host =~ /^([^:]+):(\d+)$/)
	{
		$host = $1;
		$port = $2;
	}
}
elsif (!defined($host))
{
	print "# Debug: $0 -- $1 -- $2\n" if $Munin::Plugin::SNMP::DEBUG;
	die "# Error: couldn't understand what I'm supposed to monitor.";
}

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";
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";
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";
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";
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";

my ($session, $error) = Net::SNMP->session(
		-hostname  => $host,
		-community => $community,
		-port      => $port,
		-version   => "2c"
	);

if (!defined ($session))
{
	die "Croaking: $error";
}

if ($ARGV[0] and $ARGV[0] eq "config")
{
	print "host_name $host\n" unless $host eq 'localhost';
	if (!defined ($response = $session->get_request($fcEntryDescr)))
	{
		die "Croaking: " . $session->error();
	}
	my $name = $response->{$fcEntryDescr};
	if (defined ($response = $session->get_request($fcPhysPort)))
	{
		$name .= " (" . $response->{$fcPhysPort} . ")";
	}
	print "graph_title FC $name errors\n";
	print "graph_order errs\n";
	print "graph_args --base 1000\n";
	print "graph_vlabel errors / \${graph_period}\n";
	print "graph_category network\n";
	print "graph_info This graph shows errors for fibrechannel controllers.\n";
	print "errs.info Number of errors per second on this interface.\n";
	print "errs.label errors\n";
	print "errs.type DERIVE\n";
	print "errs.min 0\n";
	print "errs.max 4000000000\n";
	exit 0;
}

my $status = 1;
if (defined ($response = $session->get_request($fcEntryStatus)))
{
	$status = $response->{$fcEntryStatus};
}

if ($status != 3)
{
	print "errs.value U\n";
	exit 0;
}

if (defined ($response = $session->get_request($fcEntryErrs)))
{
	print "errs.value ", $response->{$fcEntryErrs}, "\n";
}
else
{
	print "recv.value U\n";
}