summaryrefslogtreecommitdiffstats
path: root/contrib/check_compaq_insight.pl
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/check_compaq_insight.pl')
-rw-r--r--contrib/check_compaq_insight.pl296
1 files changed, 0 insertions, 296 deletions
diff --git a/contrib/check_compaq_insight.pl b/contrib/check_compaq_insight.pl
deleted file mode 100644
index dfb0440..0000000
--- a/contrib/check_compaq_insight.pl
+++ /dev/null
@@ -1,296 +0,0 @@
1From mm@elabnet.de Mon Nov 18 09:59:04 2002
2Date: Mon, 18 Nov 2002 12:19:04 +0100
3From: Michael Markstaller <mm@elabnet.de>
4To: nagiosplug-devel@lists.sourceforge.net
5Subject: [Nagiosplug-devel] Submission: check_insight / checking Compaq
6 Insight Agent status
7
8Hi,
9
10I've been looking to check the status/health of Compaq Insight Agents on
11servers and found a spong plugin
12(http://spong.sourceforge.net/downloads/plugins/spong-network/check_insi
13ght) which I've slightly changed to work with Nagios.
14I have pretty no idea of perl at all, just wanted to make it work for
15me, so please don't shoot me for this copy-paste-code. I've tested some
16basic things, it seems to work at least to report a warning if smthg is
17degraded and OK of xcourse ;)
18I'm also quite unsure if this is the right way to submit, so I'll just
19try ;)
20There're some "unknown" components on all servers I've checked so far,
21if anybody has a documentation of what's exactly returned when getting
22the OID 1.3.6.1.4.1.232.11.2.10.1.0 (CPQHOST_MIB isn't very descriptive)
23I'd be happy to fix this.
24
25--- cut ---
26#!/usr/bin/perl
27#
28# (c)2002 Michael Markstaller, Elaborated Networks GmbH
29# send bug reports to <mm@elabnet.de>
30#
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.
35#
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.
40#
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
45#
46#
47# Check Comapq Insight Management Agents Systems Status by SNMP
48# based on the spong-plugin check_insight from:
49#
50http://spong.sourceforge.net/downloads/plugins/spong-network/check_insig
51ht
52#
53# Usage:
54# check_insight -H <host> -C community
55#
56
57use Net::SNMP;
58use Getopt::Long;
59Getopt::Long::Configure('bundling');
60
61$version=0.01;
62
63my %ERRORS = ('UNKNOWN' , '-1',
64 'OK' , '0',
65 'WARNING', '1',
66 'CRITICAL', '2');
67
68
69#
70# some default values
71#
72$TIMEOUT=15;
73
74#
75# get command line options the regular way
76#
77GetOptions
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);
83
84#
85# handle the verbose stuff first
86#
87if ($opt_V) {
88 print "\n";
89 print "check_insight nagios plugin version $version\n";
90 print "\n";
91 print "The nagios plugins come with ABSOLUTELY NO WARRANTY. You
92may redistribute\n";
93 print "copies of the plugins under the terms of the GNU General
94Public License.\n";
95 print "For more information about these matters, see the file
96named COPYING.\n";
97 print "\n";
98 print "(c)2002 Michael Markstaller, Elaborated Networks GmbH\n";
99 print "\n";
100 print "\n";
101 exit $ERRORS{'UNKNOWN'};
102}
103
104if ($opt_h) {
105 print_help();
106 exit $ERRORS{'UNKNOWN'};
107}
108
109#
110# now get options the weired way and set the defaults
111# if nothing else is provided
112#
113$opt_H = shift unless ($opt_H);
114print_usage() unless ($opt_H);
115
116#
117# dont let us wait forever...
118#
119$SIG{'ALRM'} = sub {
120 print ("ERROR: No response from server (alarm)\n");
121 exit $ERRORS{"UNKNOWN"};
122};
123alarm($TIMEOUT);
124
125
126#
127# now we set things up for the real work
128# and fire up the request
129#
130
131########################################################################
132########
133my ($host) = ($opt_H);
134my ($color, $summary, $message ) = ( "green", "", "" );
135($opt_C) || ($opt_C = shift) || ($opt_C = "public");
136my ($community) = $opt_C;
137
138# We use some look up tables for checking some config options.
139my (@State) = ("Not Available", "Other", "OK", "Degraded", "Failed");
140
141my (@MIBName) = ("", "Std", "Unknown", "Array",
142 "Netware", "SCSI", "Health","Unknown",
143 "Store", "SM2", "Thresh", "OS", "UPS",
144 "Unknown", "IDE", "Clusters", "Fibre",
145 "MIB", "NIC");
146
147# These are the positions within the table to actually look at.
148my (@MIBs) = (1, 2, 3, 5, 6, 10, 11, 14, 18);
149
150my ($oid) = "1.3.6.1.4.1.232.11.2.10.1.0"; # SysArray
151
152# Open the connection.
153my ($session, $error) = Net::SNMP->session(Hostname => $host,
154 Community => $community);
155
156# If we can't open a connection, just return red straight away.
157if (! defined $session) {
158 print ("ERROR: Unable to contact server '$opt_H'\n");
159 exit $ERRORS{"UNKNOWN"};
160}
161
162
163$session->translate;
164my ($response) = $session->get_request($oid);
165
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"};
171 $session->close;
172 } else {
173 $session->close;
174
175 # I'm not convinced that this is the easiest way to go about this,
176this is
177 # from some code which I've inherited and I've modified for use in
178here.
179 # Hi George!
180 %h = %$response;
181 my ($d) = $h{$oid};
182
183 my (@list) = ();
184
185 # Gobble the first two char's.
186 $d = substr $d,2;
187
188 while (length($d) > 0) {
189 my ($v) = substr($d,0,2);
190 $v = hex($v);
191 $d = substr $d,2;
192 push @list, $v;
193 }
194
195 # Value in $MIBs[1] is the overall status of the machine...
196 my ($cond) = $MIBs[1];
197 $message .= "Status: $State[$cond] ";
198
199 foreach my $v (@MIBs) {
200 $cond = $list[($v*4)+1]; # A little bit of magic.
201
202 # We only bother printing the status out if it's actually
203available,
204 # as if it's N/A or Unknown then it's probably because the machine
205 # isn't available.
206 $message .= "$MIBName[$v]: $State[$cond] " if $cond > 1;
207 next if $cond < 2;
208
209 # What follows is some trickery to try and not to override a
210previous
211 # message at the same or lower color.
212 if ($cond == 4) {
213 if ($color ne 'red') {
214 $color = 'red';
215 $summary = "$MIBName[$v] is failed";
216 }
217 } elsif ($cond == 3) {
218 if ($color ne 'red') {
219 $color = 'yellow';
220 $summary = "$MIBName[$v] is degraded" if $summary eq "";
221 }
222 } elsif ($cond < 2) {
223 if ($color eq 'green') {
224 $color = 'yellow';
225 $summary = "$MIBName[$v] is unknown ($cond)" if $summary eq
226"";
227 }
228 }
229 }
230 }
231
232 $summary = "Ok" if $summary eq "";
233
234# return ($color, $summary, $message);
235
236if ($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");
244 exit $ERRORS{"OK"};
245}
246
247
248sub print_usage () {
249 print "Usage: $0 -H <host> -C <community> \n"; }
250
251sub print_help () {
252 print "\n";
253 print "\n";
254 print "check_insight nagios plugin version $version\n";
255 print "\n";
256 print "The nagios plugins come with ABSOLUTELY NO WARRANTY. You
257may redistribute\n";
258 print "copies of the plugins under the terms of the GNU General
259Public License.\n";
260 print "For more information about these matters, see the file
261named COPYING.\n";
262 print "\n";
263 print "(c)2002 Michael Markstaller, Elaborated Networks GmbH\n";
264 print "\n";
265 print "\n";
266 print "This plugin checks the Compaq Insight Management agents
267system status via SNMP on the specified host.\n";
268 print "\n";
269 print "\n";
270 print_usage();
271 print "\n";
272 print "Options:\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";
281 print "\n";
282 print "\n";
283}
284--- cut ---
285
286Michael
287
288
289-------------------------------------------------------
290This sf.net email is sponsored by: To learn the basics of securing
291your web site with SSL, click here to get a FREE TRIAL of a Thawte
292Server Certificate: http://www.gothawte.com/rd524.html
293_______________________________________________
294Nagiosplug-devel mailing list
295Nagiosplug-devel@lists.sourceforge.net
296https://lists.sourceforge.net/lists/listinfo/nagiosplug-devel