Projet

Général

Profil

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

root / plugins / snmp / snmp__gwmta_msgs_ @ 7da1b039

Historique | Voir | Annoter | Télécharger (5,83 ko)

1
#!/usr/bin/perl -w
2
#
3
# File: snmp__gwmta_msgs_
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 MTA (GWMTA)
25
# ------------------------------------------------------------
26
# 
27
# Management Information Base (MIB) GWMTA-MIB 
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 GWMTA, type
33
# snmpwalk -v1 -c public -m GWMTA-MIB <HOST> gwmta
34
#
35
# This plugin fetches:  
36
#
37
# * mtaDomainName 1.3.6.1.4.1.23.2.37.1.1.1.2. 
38
# * mtaTenMinuteRoutedMsgs - 1.3.6.1.4.1.23.2.37.1.1.1.10. 
39
# * mtaTenMinuteUndeliverableMsgs - 1.3.6.1.4.1.23.2.37.1.1.1.12.
40
# * mtaTenMinuteErrorMsgs - 1.3.6.1.4.1.23.2.37.1.1.1.14.
41
#
42
# Usage:
43
# --------------
44
# Link this file snmp__gwmta_msgs_ to your nodes servicedir [/etc/munin/plugins] 
45
#
46
# as: 
47
#   snmp_<host>_gwmta_msgs_<pos>  
48
#
49
# with:
50
#   <host> = Name or IP-Number of host 
51
#   <pos> = table index of the GWMTA Object
52
# 
53
# E.g.
54
#    ln -s /usr/share/munin/plugins/snmp__gwmta_msgs_ \
55
#    /etc/munin/plugins/snmp_foo.example.com_gwmta_msgs_0
56
# ...will monitor a single GWMTA object on host foo.example.com. 
57
#
58
# Parameters
59
#	community - Specify wich community string to use (Default: public)
60
# 	port - Specify which port to read from (Default: 161)
61
#	host - Specify which host to monitor (Default: Read from link in servicedir)
62
#	pos - Specify which table Object to read (Default: Read from link in servicedir, 
63
# 
64
# You may adjust settings to your need via configuration in plugin-conf.d/munin-node:
65
#   [snmp_*_gwmta_msgs_*]
66
#   env.port <your_port_number>
67
#   env.community <your SNMP community string>
68
#   env.pos <your objects table position. Values: 0,1,2,..> 
69
#   env.host <name or IP of your host>
70
#
71
# Parameters can also be specified on a per GWMTA basis, eg:
72
#   [snmp_example.com_gwmta_msgs_1]
73
#   env.port 166
74
#   env.community example
75
#
76
# $Log$
77
# Revision 1.0	2007/09/08 19:44	gap
78
# Created by gap
79
#
80
#%# family=snmpauto
81
#%# capabilities=snmpconf
82

    
83
use strict;
84
use Net::SNMP;
85

    
86
my $DEBUG = 0;
87

    
88
my $host      = $ENV{host}      || undef;
89
my $port      = $ENV{port}      || 161;
90
my $community = $ENV{community} || "public";
91
my $pos       = $ENV{pos} || 1;
92

    
93
my $response;
94

    
95
# fix values
96
my $GRAPH_CATEGORY = "Groupwise";
97
my $GRAPH_PERIOD = "minute";
98
my $GRAPH_VLABEL = "number of messages / 10 min";
99
my $ROUTED_LABEL="Routed";
100
my $ROUTED_CRITICAL=500;
101
my $UNDELIVERED_LABEL="Undeliverable";
102
my $UNDELIVERED_CRITICAL=10;
103
my $ERRORS_LABEL="Errors";
104
my $ERRORS_CRITICAL=10;
105

    
106
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
107
{
108
	print "index 1.3.6.1.4.1.23.2.37.1.1.1.1.\n"; # mtaIndex 	
109
	print "require 1.3.6.1.4.1.23.2.37.1.1.1.2. \n"; # mtaDomainName 
110
	print "require 1.3.6.1.4.1.23.2.37.1.1.1.10. [\\d+]\n"; # mtaTenMinuteRoutedMsgs
111
	print "require 1.3.6.1.4.1.23.2.37.1.1.1.12. [\\d+]\n"; # mtaTenMinuteUndeliverableMsgs
112
	print "require 1.3.6.1.4.1.23.2.37.1.1.1.14. [\\d+]\n"; # mtaTenMinuteErrorMsgs
113

    
114
	exit 0;
115
}
116

    
117
if ($0 =~ /^(?:|.*\/)snmp_([^_]+)_gwmta_msgs_(\d+)*$/)
118
{
119
	$host  = $1;
120
	$pos   = $2;
121
}
122
elsif (!defined($host))
123
{
124
	print "# Debug: $0 -- $1\n" if $DEBUG;
125
	die "# Error: couldn't understand what I'm supposed to monitor.";
126
}
127

    
128
my ($session, $error) = Net::SNMP->session(
129
		-hostname  => $host,
130
		-community => $community,
131
		-port      => $port
132
	);
133

    
134
if (!defined ($session))
135
{
136
	die "Croaking: $error";
137
}
138

    
139
if (defined $ARGV[0] and $ARGV[0] eq "config")
140
{
141
	# get name of domain 
142
	my $domain = &get_single ($session, "1.3.6.1.4.1.23.2.37.1.1.1.2.$pos"); # mtaDomainName 
143

    
144
        # output to munin
145
	print "host_name $host
146
graph_category Groupwise
147
graph_args --base 1000
148
graph_period $GRAPH_PERIOD
149
graph_title GWMTA load ($domain) 
150
graph_info Monitors status of Groupwise MTA, here: $domain. It reports values for the last 10 minutes. 
151
graph_vlabel $GRAPH_VLABEL
152
graph_args -l 0
153
routed.label $ROUTED_LABEL
154
routed.info mtaTenMinuteRoutedMsgs (1.3.6.1.4.1.23.2.37.1.1.1.10.) 
155
routed.critical $ROUTED_CRITICAL
156
routed.type GAUGE
157
routed.min 0
158
routed.draw  AREA
159
routed.graph yes
160
undelivered.label $UNDELIVERED_LABEL
161
undelivered.info mtaTenMinuteUndeliverableMsgs (1.3.6.1.4.1.23.2.37.1.1.1.12.)
162
undelivered.critical $UNDELIVERED_CRITICAL
163
undelivered.type GAUGE
164
undelivered.min 0
165
undelivered.draw  STACK
166
undelivered.graph  yes
167
errors.label $ERRORS_LABEL
168
errors.info mtaTenMinuteErrorMsgs (1.3.6.1.4.1.23.2.37.1.1.1.14.)
169
errors.critical $ERRORS_CRITICAL
170
errors.type GAUGE
171
errors.min 0
172
errors.draw STACK
173
errors.graph yes";
174

    
175
	exit 0;
176
}
177
	# fetch the data and print
178
	print "routed.value ", &get_single ($session, "1.3.6.1.4.1.23.2.37.1.1.1.10.$pos"), "\n"; # mtaTenMinuteRoutedMsgs
179
	print "undelivered.value ", &get_single ($session, "1.3.6.1.4.1.23.2.37.1.1.1.12.$pos"), "\n"; # mtaTenMinuteUndeliverableMsgs
180
	print "errors.value ", &get_single ($session, "1.3.6.1.4.1.23.2.37.1.1.1.14.$pos"), "\n"; # mtaTenMinuteErrorMsgs
181

    
182
sub get_single
183
{
184
	my $handle = shift;
185
	my $oid    = shift;
186

    
187
	print "# Getting single $oid...\n" if $DEBUG;
188

    
189
	$response = $handle->get_request ($oid);
190

    
191
	if (!defined $response->{$oid})
192
	{
193
	    return undef;
194
	}
195
	else
196
	{
197
	    return $response->{$oid};
198
	}
199
}
200