1
From mm@elabnet.de Mon Nov 18 09:59:04 2002
2
Date: Mon, 18 Nov 2002 12:19:04 +0100
3
From: Michael Markstaller <mm@elabnet.de>
4
To: nagiosplug-devel@lists.sourceforge.net
5
Subject: [Nagiosplug-devel] Submission: check_insight / checking Compaq
10
I've been looking to check the status/health of Compaq Insight Agents on
11
servers and found a spong plugin
12
(http://spong.sourceforge.net/downloads/plugins/spong-network/check_insi
13
ght) which I've slightly changed to work with Nagios.
14
I have pretty no idea of perl at all, just wanted to make it work for
15
me, so please don't shoot me for this copy-paste-code. I've tested some
16
basic things, it seems to work at least to report a warning if smthg is
17
degraded and OK of xcourse ;)
18
I'm also quite unsure if this is the right way to submit, so I'll just
20
There're some "unknown" components on all servers I've checked so far,
21
if anybody has a documentation of what's exactly returned when getting
22
the OID 1.3.6.1.4.1.232.11.2.10.1.0 (CPQHOST_MIB isn't very descriptive)
23
I'd be happy to fix this.
28
# (c)2002 Michael Markstaller, Elaborated Networks GmbH
29
# send bug reports to <mm@elabnet.de>
31
# This program is free software; you can redistribute it and/or
32
# modify it under the terms of the GNU General Public License
33
# as published by the Free Software Foundation; either version 2
34
# of the License, or (at your option) any later version.
36
# This program is distributed in the hope that it will be useful,
37
# but WITHOUT ANY WARRANTY; without even the implied warranty
38
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39
# GNU General Public License for more details.
41
# you should have received a copy of the GNU General Public License
42
# along with this program (or with Nagios); if not, write to the
43
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
44
# Boston, MA 02111-1307, USA
47
# Check Comapq Insight Management Agents Systems Status by SNMP
48
# based on the spong-plugin check_insight from:
50
http://spong.sourceforge.net/downloads/plugins/spong-network/check_insig
54
# check_insight -H <host> -C community
59
Getopt::Long::Configure('bundling');
63
my %ERRORS = ('UNKNOWN' , '-1',
75
# get command line options the regular way
78
("V" => \$opt_V, "version" => \$opt_V,
79
"h" => \$opt_h, "help" => \$opt_h,
80
"v" => \$verbose, "verbose" => \$verbose,
81
"H=s" => \$opt_H, "hostname=s" => \$opt_H,
82
"C=s" => \$opt_C, "community=s" => \$opt_C);
85
# handle the verbose stuff first
89
print "check_insight nagios plugin version $version\n";
91
print "The nagios plugins come with ABSOLUTELY NO WARRANTY. You
93
print "copies of the plugins under the terms of the GNU General
95
print "For more information about these matters, see the file
98
print "(c)2002 Michael Markstaller, Elaborated Networks GmbH\n";
101
exit $ERRORS{'UNKNOWN'};
106
exit $ERRORS{'UNKNOWN'};
110
# now get options the weired way and set the defaults
111
# if nothing else is provided
113
$opt_H = shift unless ($opt_H);
114
print_usage() unless ($opt_H);
117
# dont let us wait forever...
120
print ("ERROR: No response from server (alarm)\n");
121
exit $ERRORS{"UNKNOWN"};
127
# now we set things up for the real work
128
# and fire up the request
131
########################################################################
133
my ($host) = ($opt_H);
134
my ($color, $summary, $message ) = ( "green", "", "" );
135
($opt_C) || ($opt_C = shift) || ($opt_C = "public");
136
my ($community) = $opt_C;
138
# We use some look up tables for checking some config options.
139
my (@State) = ("Not Available", "Other", "OK", "Degraded", "Failed");
141
my (@MIBName) = ("", "Std", "Unknown", "Array",
142
"Netware", "SCSI", "Health","Unknown",
143
"Store", "SM2", "Thresh", "OS", "UPS",
144
"Unknown", "IDE", "Clusters", "Fibre",
147
# These are the positions within the table to actually look at.
148
my (@MIBs) = (1, 2, 3, 5, 6, 10, 11, 14, 18);
150
my ($oid) = "1.3.6.1.4.1.232.11.2.10.1.0"; # SysArray
152
# Open the connection.
153
my ($session, $error) = Net::SNMP->session(Hostname => $host,
154
Community => $community);
156
# If we can't open a connection, just return red straight away.
157
if (! defined $session) {
158
print ("ERROR: Unable to contact server '$opt_H'\n");
159
exit $ERRORS{"UNKNOWN"};
164
my ($response) = $session->get_request($oid);
166
if (!defined $response) {
167
# If there's no response, something screwy is going on, give up.
168
$summary = $session->error;
169
print ("ERROR: $summary\n");
170
exit $ERRORS{"UNKNOWN"};
175
# I'm not convinced that this is the easiest way to go about this,
177
# from some code which I've inherited and I've modified for use in
185
# Gobble the first two char's.
188
while (length($d) > 0) {
189
my ($v) = substr($d,0,2);
195
# Value in $MIBs[1] is the overall status of the machine...
196
my ($cond) = $MIBs[1];
197
$message .= "Status: $State[$cond] ";
199
foreach my $v (@MIBs) {
200
$cond = $list[($v*4)+1]; # A little bit of magic.
202
# We only bother printing the status out if it's actually
204
# as if it's N/A or Unknown then it's probably because the machine
206
$message .= "$MIBName[$v]: $State[$cond] " if $cond > 1;
209
# What follows is some trickery to try and not to override a
211
# message at the same or lower color.
213
if ($color ne 'red') {
215
$summary = "$MIBName[$v] is failed";
217
} elsif ($cond == 3) {
218
if ($color ne 'red') {
220
$summary = "$MIBName[$v] is degraded" if $summary eq "";
222
} elsif ($cond < 2) {
223
if ($color eq 'green') {
225
$summary = "$MIBName[$v] is unknown ($cond)" if $summary eq
232
$summary = "Ok" if $summary eq "";
234
# return ($color, $summary, $message);
236
if ($color eq 'red') {
237
print ("red Output: $message\n");
238
exit $ERRORS{"CRITICAL"};
239
} elsif ($color eq 'yellow') {
240
print ("$summary $message\n");
241
exit $ERRORS{"WARNING"};
242
} elsif ($color eq 'green') {
243
print ("$message\n");
249
print "Usage: $0 -H <host> -C <community> \n"; }
254
print "check_insight nagios plugin version $version\n";
256
print "The nagios plugins come with ABSOLUTELY NO WARRANTY. You
258
print "copies of the plugins under the terms of the GNU General
260
print "For more information about these matters, see the file
263
print "(c)2002 Michael Markstaller, Elaborated Networks GmbH\n";
266
print "This plugin checks the Compaq Insight Management agents
267
system status via SNMP on the specified host.\n";
273
print " -H, --hostname=ADDRESS\n";
274
print " host name argument for server.\n";
275
print " -C, --community=STRING\n";
276
print " SNMP Read-community string.\n";
277
print " -h, --help\n";
278
print " print detailed help screen.\n";
279
print " -V, --version\n";
280
print " print version information.\n";
289
-------------------------------------------------------
290
This sf.net email is sponsored by: To learn the basics of securing
291
your web site with SSL, click here to get a FREE TRIAL of a Thawte
292
Server Certificate: http://www.gothawte.com/rd524.html
293
_______________________________________________
294
Nagiosplug-devel mailing list
295
Nagiosplug-devel@lists.sourceforge.net
296
https://lists.sourceforge.net/lists/listinfo/nagiosplug-devel