diff options
-rw-r--r-- | contrib/check_adptraid.sh | 75 | ||||
-rw-r--r-- | contrib/check_compaq_insight.pl | 296 | ||||
-rwxr-xr-x | contrib/check_file_age.pl | 113 |
3 files changed, 484 insertions, 0 deletions
diff --git a/contrib/check_adptraid.sh b/contrib/check_adptraid.sh new file mode 100644 index 0000000..d7f8d0c --- /dev/null +++ b/contrib/check_adptraid.sh | |||
@@ -0,0 +1,75 @@ | |||
1 | #! /bin/sh | ||
2 | # | ||
3 | # Modified check_sensors to check the alarm status of an Adaptec 3200S RAID | ||
4 | # controller. | ||
5 | # | ||
6 | # Scott Lambert -- lambert@lambertfam.org | ||
7 | # | ||
8 | # Tested on FreeBSD 4.7 with the adptfbsd_323.tgz package installed. This | ||
9 | # package installs all it's programs into /usr/dpt. | ||
10 | # | ||
11 | |||
12 | PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin | ||
13 | |||
14 | PROGNAME=`basename $0` | ||
15 | PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` | ||
16 | REVISION=`echo '$Revision$' | sed -e 's/[^0-9.]//g'` | ||
17 | |||
18 | . $PROGPATH/utils.sh | ||
19 | |||
20 | RAIDUTIL_CMD="/usr/dpt/raidutil -A ?" | ||
21 | |||
22 | print_usage() { | ||
23 | echo "Usage: $PROGNAME" | ||
24 | } | ||
25 | |||
26 | print_help() { | ||
27 | print_revision $PROGNAME $REVISION | ||
28 | echo "" | ||
29 | print_usage | ||
30 | echo "" | ||
31 | echo "This plugin checks alarm status of Adaptec 3200S RAID controller." | ||
32 | echo "" | ||
33 | support | ||
34 | exit 0 | ||
35 | } | ||
36 | |||
37 | case "$1" in | ||
38 | --help) | ||
39 | print_help | ||
40 | exit 0 | ||
41 | ;; | ||
42 | -h) | ||
43 | print_help | ||
44 | exit 0 | ||
45 | ;; | ||
46 | --version) | ||
47 | print_revision $PROGNAME $REVISION | ||
48 | exit 0 | ||
49 | ;; | ||
50 | -V) | ||
51 | print_revision $PROGNAME $REVISION | ||
52 | exit 0 | ||
53 | ;; | ||
54 | *) | ||
55 | raidutiloutput=`$RAIDUTIL_CMD 2>&1` | ||
56 | status=$? | ||
57 | if test "$1" = "-v" -o "$1" = "--verbose"; then | ||
58 | echo ${raidutiloutput} | ||
59 | fi | ||
60 | if test ${status} -eq 127; then | ||
61 | echo "RAIDUTIL UNKNOWN - command not found (did you install raidutil?)" | ||
62 | exit -1 | ||
63 | elif test ${status} -ne 0 ; then | ||
64 | echo "WARNING - raidutil returned state $status" | ||
65 | exit 1 | ||
66 | fi | ||
67 | if echo ${raidutiloutput} | egrep On > /dev/null; then | ||
68 | echo RAID CRITICAL - RAID alarm detected! | ||
69 | exit 2 | ||
70 | else | ||
71 | echo raid ok | ||
72 | exit 0 | ||
73 | fi | ||
74 | ;; | ||
75 | esac | ||
diff --git a/contrib/check_compaq_insight.pl b/contrib/check_compaq_insight.pl new file mode 100644 index 0000000..dfb0440 --- /dev/null +++ b/contrib/check_compaq_insight.pl | |||
@@ -0,0 +1,296 @@ | |||
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 | ||
6 | Insight Agent status | ||
7 | |||
8 | Hi, | ||
9 | |||
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 | ||
19 | try ;) | ||
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. | ||
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 | # | ||
50 | http://spong.sourceforge.net/downloads/plugins/spong-network/check_insig | ||
51 | ht | ||
52 | # | ||
53 | # Usage: | ||
54 | # check_insight -H <host> -C community | ||
55 | # | ||
56 | |||
57 | use Net::SNMP; | ||
58 | use Getopt::Long; | ||
59 | Getopt::Long::Configure('bundling'); | ||
60 | |||
61 | $version=0.01; | ||
62 | |||
63 | my %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 | # | ||
77 | GetOptions | ||
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 | # | ||
87 | if ($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 | ||
92 | may redistribute\n"; | ||
93 | print "copies of the plugins under the terms of the GNU General | ||
94 | Public License.\n"; | ||
95 | print "For more information about these matters, see the file | ||
96 | named 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 | |||
104 | if ($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); | ||
114 | print_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 | }; | ||
123 | alarm($TIMEOUT); | ||
124 | |||
125 | |||
126 | # | ||
127 | # now we set things up for the real work | ||
128 | # and fire up the request | ||
129 | # | ||
130 | |||
131 | ######################################################################## | ||
132 | ######## | ||
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; | ||
137 | |||
138 | # We use some look up tables for checking some config options. | ||
139 | my (@State) = ("Not Available", "Other", "OK", "Degraded", "Failed"); | ||
140 | |||
141 | my (@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. | ||
148 | my (@MIBs) = (1, 2, 3, 5, 6, 10, 11, 14, 18); | ||
149 | |||
150 | my ($oid) = "1.3.6.1.4.1.232.11.2.10.1.0"; # SysArray | ||
151 | |||
152 | # Open the connection. | ||
153 | my ($session, $error) = Net::SNMP->session(Hostname => $host, | ||
154 | Community => $community); | ||
155 | |||
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"}; | ||
160 | } | ||
161 | |||
162 | |||
163 | $session->translate; | ||
164 | my ($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, | ||
176 | this is | ||
177 | # from some code which I've inherited and I've modified for use in | ||
178 | here. | ||
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 | ||
203 | available, | ||
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 | ||
210 | previous | ||
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 | |||
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"); | ||
244 | exit $ERRORS{"OK"}; | ||
245 | } | ||
246 | |||
247 | |||
248 | sub print_usage () { | ||
249 | print "Usage: $0 -H <host> -C <community> \n"; } | ||
250 | |||
251 | sub 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 | ||
257 | may redistribute\n"; | ||
258 | print "copies of the plugins under the terms of the GNU General | ||
259 | Public License.\n"; | ||
260 | print "For more information about these matters, see the file | ||
261 | named 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 | ||
267 | system 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 | |||
286 | Michael | ||
287 | |||
288 | |||
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 | ||
diff --git a/contrib/check_file_age.pl b/contrib/check_file_age.pl new file mode 100755 index 0000000..ae9311e --- /dev/null +++ b/contrib/check_file_age.pl | |||
@@ -0,0 +1,113 @@ | |||
1 | #!/bin/perl -w | ||
2 | # $Id$ | ||
3 | |||
4 | # check_file.pl Copyright (C) 2003 Steven Grimm <koreth-nagios@midwinter.com> | ||
5 | # | ||
6 | # Checks a file's size and modification time to make sure it's not empty | ||
7 | # and that it's sufficiently recent. | ||
8 | # | ||
9 | # | ||
10 | # This program is free software; you can redistribute it and/or | ||
11 | # modify it under the terms of the GNU General Public License | ||
12 | # as published by the Free Software Foundation; either version 2 | ||
13 | # of the License, or (at your option) any later version. | ||
14 | # | ||
15 | # This program is distributed in the hope that it will be useful, | ||
16 | # but WITHOUT ANY WARRANTY; without even the implied warranty | ||
17 | # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | # GNU General Public License for more details. | ||
19 | # | ||
20 | # you should have received a copy of the GNU General Public License | ||
21 | # along with this program (or with Nagios); if not, write to the | ||
22 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
23 | # Boston, MA 02111-1307, USA | ||
24 | |||
25 | use strict; | ||
26 | use English; | ||
27 | use Getopt::Long; | ||
28 | use File::stat; | ||
29 | use vars qw($PROGNAME); | ||
30 | use lib utils.pm; | ||
31 | use utils qw (%ERRORS &print_revision &support); | ||
32 | |||
33 | sub print_help (); | ||
34 | sub print_usage (); | ||
35 | |||
36 | my ($opt_c, $opt_f, $opt_w, $opt_C, $opt_W, $opt_h, $opt_V); | ||
37 | my ($result, $message, $age, $size, $st); | ||
38 | |||
39 | $PROGNAME="check_file"; | ||
40 | |||
41 | $opt_w = 240; | ||
42 | $opt_c = 600; | ||
43 | $opt_W = 0; | ||
44 | $opt_C = 0; | ||
45 | $opt_f = ""; | ||
46 | |||
47 | Getopt::Long::Configure('bundling'); | ||
48 | GetOptions( | ||
49 | "V" => \$opt_V, "version" => \$opt_V, | ||
50 | "h" => \$opt_h, "help" => \$opt_h, | ||
51 | "f=s" => \$opt_f, "file" => \$opt_f, | ||
52 | "w=f" => \$opt_w, "warning-age=f" => \$opt_w, | ||
53 | "W=f" => \$opt_W, "warning-size=f" => \$opt_W, | ||
54 | "c=f" => \$opt_c, "critical-age=f" => \$opt_c, | ||
55 | "C=f" => \$opt_C, "critical-size=f" => \$opt_C); | ||
56 | |||
57 | if ($opt_V) { | ||
58 | print_revision($PROGNAME, '$Id$'); | ||
59 | exit $ERRORS{'OK'}; | ||
60 | } | ||
61 | |||
62 | if ($opt_h) { | ||
63 | print_help(); | ||
64 | exit $ERRORS{'OK'}; | ||
65 | } | ||
66 | |||
67 | $opt_f = shift unless ($opt_f); | ||
68 | |||
69 | if (! $opt_f) { | ||
70 | print "No file specified\n"; | ||
71 | exit $ERRORS{'UNKNOWN'}; | ||
72 | } | ||
73 | |||
74 | # Examine the file. | ||
75 | unless (-f $opt_f) { | ||
76 | print "$opt_f: File not found\n"; | ||
77 | exit $ERRORS{'UNKNOWN'}; | ||
78 | } | ||
79 | |||
80 | $st = File::stat::stat($opt_f); | ||
81 | $age = time - $st->mtime; | ||
82 | $size = $st->size; | ||
83 | |||
84 | |||
85 | $result = 'OK'; | ||
86 | |||
87 | if (($opt_c and $age > $opt_c) or ($opt_C and $size < $opt_C)) { | ||
88 | $result = 'CRITICAL'; | ||
89 | } | ||
90 | elsif (($opt_w and $age > $opt_w) or ($opt_W and $size < $opt_W)) { | ||
91 | $result = 'WARNING'; | ||
92 | } | ||
93 | |||
94 | print "$result - $opt_f is $age seconds old and $size bytes\n"; | ||
95 | exit $ERRORS{$result}; | ||
96 | |||
97 | sub print_usage () { | ||
98 | print "Usage:\n"; | ||
99 | print " $PROGNAME [-w <secs>] [-c <secs>] [-W <size>] [-C <size>] -f <file>\n"; | ||
100 | print " $PROGNAME [-h | --help]\n"; | ||
101 | print " $PROGNAME [-V | --version]\n"; | ||
102 | } | ||
103 | |||
104 | sub print_help () { | ||
105 | print_revision($PROGNAME, '$Id$'); | ||
106 | print "Copyright (c) 2003 Steven Grimm\n\n"; | ||
107 | print_usage(); | ||
108 | print "\n"; | ||
109 | print " <secs> File must be no more than this many seconds old\n"; | ||
110 | print " <size> File must be at least this many bytes long\n"; | ||
111 | print "\n"; | ||
112 | support(); | ||
113 | } | ||