Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / snmp / snmp__gwpoa_ @ ef960abc

Historique | Voir | Annoter | Télécharger (6,14 ko)

1
#!/usr/bin/perl -w
2
#
3
# File: snmp__gwpoa_
4
# Copyright (C) 2007 Gabriele Pohl (contact@dipohl.de)
5
#
6
# Derived from plugin snmp__load
7
# Copyright (C) 2004 Jimmy Olsen, Dagfinn Ilmari Mannsaaker
8
#
9
# This program is free software; you can redistribute it and/or
10
# modify it under the terms of the GNU General Public License
11
# as published by the Free Software Foundation; version 2 dated June,
12
# 1991.
13
#
14
# This program is distributed in the hope that it will be useful,
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
# GNU General Public License for more details.
18
#
19
# You should have received a copy of the GNU General Public License
20
# along with this program; if not, write to the Free Software
21
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
#
23
# ------------------------------------------------------------
24
# Plugin to monitor Novell Groupwise Post Office Agent (POA)
25
# ------------------------------------------------------------
26
# 
27
# Management Information Base (MIB) GWPOA 
28
#
29
# Naming Tree: 1.3.6.1.4.1.23
30
#      iso(1) org(3) dod(6) internet(1) private(4) enterprises(1) novell(23)
31
#
32
# To see all values available for your GWPOA, type
33
# snmpwalk -v1 -c public -m GWPOA-MIB <HOST> gwpoa
34
#
35
# This plugin fetches:  
36
#
37
# * poaPostOfficeName - 1.3.6.1.4.1.23.2.38.1.1.1.2.
38
# * poaTotalMsgs - 1.3.6.1.4.1.23.2.38.1.1.1.3.
39
# * poaUndeliverableMsgs - 1.3.6.1.4.1.23.2.38.1.1.1.8.
40
# * poaProblemMsgs - 1.3.6.1.4.1.23.2.38.1.1.1.4.
41
# * poaAdmErrorMsg - 1.3.6.1.4.1.23.2.38.1.1.1.27.
42
#
43
# Usage:
44
# --------------
45
# Plugin needs to be linked to your servicedir [/etc/munin/plugins]
46
# with the hostname (host) and the table index (pos) of the POA-Object
47
# defined in the linkage.
48
#
49
#   snmp_<host>_gwpoa_<pos>  
50
#
51
# with:
52
#   <host> = Name or IP-Number of host 
53
#   <pos> = Table index of the POA Object
54
#
55
#
56
# E.g.
57
#    ln -s /usr/share/munin/plugins/snmp__gwpoa_ \
58
#    /etc/munin/plugins/snmp_foo.example.com_gwpoa_1
59
#
60
# ...will monitor the first POA-Object on host foo.example.com. 
61
#
62
#
63
# Configuration:
64
# --------------
65
# Parameters
66
#	community - Specify wich community string to use (Default: public)
67
# 	port - Specify which port to read from (Default: 161)
68
#	host - Specify which host to monitor (Default: Read from link in servicedir)
69
#	pos - Specify which table Object to read (Default: Read from link in servicedir, 
70
# 
71
# You may adjust settings via configuration in plugin-conf.d/munin-node:
72
#   [snmp_*_gwpoa_*]
73
#   env.port <your_port_number>
74
#   env.community <your SNMP community string>
75
#   env.pos <your table position. Values: 0,1,2,..> 
76
#   env.host <name or IP of your host>
77
#
78
# Parameters can also be specified on a per POA basis, eg:
79
#   [snmp_foo.example.com_gwpoa_2]
80
#   env.port 166
81
#   env.community example
82
#
83
# $Log$
84
# Revision 1.0	2007/09/02 11:27	gap
85
# Created by gap
86
#
87
#
88
#%# family=snmpauto
89
#%# capabilities=snmpconf
90

    
91
use strict;
92
use Net::SNMP;
93

    
94
my $DEBUG = 0;
95

    
96
my $host      = $ENV{host}      || undef;
97
my $port      = $ENV{port}      || 161;
98
my $community = $ENV{community} || "public";
99
my $pos       = $ENV{pos} || 1;
100

    
101
my $response;
102

    
103
my $GRAPH_CATEGORY = "Groupwise";
104
my $GRAPH_PERIOD = "minute";
105
my $GRAPH_VLABEL = "messages per $GRAPH_PERIOD";
106
my $TOTAL_LABEL = "TotalMsgs";
107
my $UNDELIVERABLE_LABEL = "UndeliverableMsgs";	
108
my $PROBLEM_LABEL = "ProblemMsgs";
109
my $ERRORS_LABEL = "AdmErrorMsgs";
110
my $ERRORS_CRITICAL = 10;
111

    
112
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
113
{
114
	print "index 1.3.6.1.4.1.23.2.38.1.1.1.1.\n"; # gwpoa 
115
	print "require 1.3.6.1.4.1.23.2.38.1.1.1.2. [.*]\n"; # poaPostOfficeName 
116
	print "require 1.3.6.1.4.1.23.2.38.1.1.1.3. [\\d*]\n"; # poaTotalMsgs
117
	print "require 1.3.6.1.4.1.23.2.38.1.1.1.4. [\\d*]\n"; # poaProblemMsgs
118
	print "require 1.3.6.1.4.1.23.2.38.1.1.1.8. [\\d*]\n"; # poaUndeliverableMsgs
119
	print "require 1.3.6.1.4.1.23.2.38.1.1.1.27. [\\d*]\n"; # poaAdmErrorMsgs
120

    
121
	exit 0;
122
}
123
if ($0 =~ /^(?:|.*\/)snmp_([^_]+)_gwpoa_(\d+)*$/)
124
{
125
	$host  = $1;
126
	# take default value for pos if not set in link
127
	if (defined($2)) { $pos   = $2; }
128
}
129
elsif (!defined($host))
130
{
131
	print "# Debug: $0 -- $1\n" if $DEBUG;
132
	die "# Error: couldn't understand what I'm supposed to monitor.";
133
}
134

    
135
my ($session, $error) = Net::SNMP->session(
136
		-hostname  => $host,
137
		-community => $community,
138
		-port      => $port
139
	);
140

    
141
if (!defined ($session))
142
{
143
	die "Croaking: $error";
144
}
145

    
146
if (defined $ARGV[0] and $ARGV[0] eq "config")
147
{
148

    
149
	# get Post Office Name 
150
	my $poname = &get_single ($session, "1.3.6.1.4.1.23.2.38.1.1.1.2.$pos"); # poaPostOfficeName 
151

    
152
	# output to munin
153
	print "host_name $host
154
graph_category $GRAPH_CATEGORY
155
graph_args --base 1000
156
graph_period $GRAPH_PERIOD
157
graph_title GWPOA load ($poname)
158
graph_info Shows per minute activity of the Groupwise PostOfficeAgent (GWPOA), here: $poname.<br />
159
graph_vlabel $GRAPH_VLABEL
160
total_msgs.label $TOTAL_LABEL
161
total_msgs.info poaTotalMsgs
162
total_msgs.type DERIVE
163
total_msgs.min 0
164
total_msgs.draw LINE2
165
total_msgs.graph yes
166
problem_msgs.label $PROBLEM_LABEL
167
problem_msgs.info poaProblemMsgs
168
problem_msgs.type DERIVE
169
problem_msgs.min 0
170
problem_msgs.draw LINE2
171
problem_msgs.graph yes
172
undeliverable_msgs.label $UNDELIVERABLE_LABEL
173
undeliverable_msgs.info poaUndeliverableMsgs
174
undeliverable_msgs.type DERIVE
175
undeliverable_msgs.min 0
176
undeliverable_msgs.draw LINE2
177
undeliverable_msgs.graph yes
178
errors.label $ERRORS_LABEL
179
errors.info poaAdmErrorMsgs
180
errors.critical $ERRORS_CRITICAL
181
errors.type DERIVE
182
errors.min 0
183
errors.draw LINE2
184
errors_out.graph yes";
185

    
186
	exit 0;
187
}
188
	# fetch the data and print
189
	print "total_msgs.value ", &get_single ($session, "1.3.6.1.4.1.23.2.38.1.1.1.3.$pos"), "\n"; # poaTotalMsgs
190
	print "problem_msgs.value ", &get_single ($session, "1.3.6.1.4.1.23.2.38.1.1.1.4.$pos"), "\n"; # poaProblemMsgs
191
	print "undeliverable_msgs.value ", &get_single ($session, "1.3.6.1.4.1.23.2.38.1.1.1.8.$pos"), "\n"; # poaUndeliverableMsgs
192
	print "errors.value ", &get_single ($session, "1.3.6.1.4.1.23.2.38.1.1.1.27.$pos"), "\n"; # poaAdmErrorMsgs
193

    
194

    
195
sub get_single
196
{
197
	my $handle = shift;
198
	my $oid    = shift;
199

    
200
	print "# Getting single $oid...\n" if $DEBUG;
201

    
202
	$response = $handle->get_request ($oid);
203

    
204
	if (!defined $response->{$oid})
205
	{
206
	    return undef;
207
	}
208
	else
209
	{
210
	    return $response->{$oid};
211
	}
212
}
213