[project @ peter@palfrader.org-20080429130157-1bm1hy9fy9no2y19]
authorPeter Palfrader <peter@palfrader.org>
Tue, 29 Apr 2008 13:01:57 +0000 (13:01 +0000)
committerPeter Palfrader <peter@palfrader.org>
Tue, 29 Apr 2008 13:01:57 +0000 (13:01 +0000)
A raid check for master

dsa-nagios-nrpe-config/debian/changelog
dsa-nagios-nrpe-config/debian/rules
dsa-nagios-nrpe-config/dsa-check-raid-mpt [new file with mode: 0755]
nagios-master.cfg

index 57055c2..c089d2c 100644 (file)
@@ -1,3 +1,9 @@
+dsa-nagios-nrpe-config (35) unstable; urgency=low
+
+  * dsa-check-raid-mpt
+
+ -- Peter Palfrader <weasel@debian.org>  Tue, 29 Apr 2008 12:57:50 +0000
+
 dsa-nagios-nrpe-config (34) unstable; urgency=low
 
   * dsa-check-raid-3ware
index 4e774a5..df8c8b0 100755 (executable)
@@ -15,6 +15,7 @@ install:
 
        install -m 644 nrpe_dsa.cfg $(CURDIR)/debian/dsa-nagios-nrpe-config/etc/nagios
        install -m 755 dsa-check-raid-dac960 $(CURDIR)/debian/dsa-nagios-nrpe-config/usr/lib/nagios/plugins
+       install -m 755 dsa-check-raid-mpt $(CURDIR)/debian/dsa-nagios-nrpe-config/usr/lib/nagios/plugins
        install -m 755 dsa-check-raid-sw $(CURDIR)/debian/dsa-nagios-nrpe-config/usr/lib/nagios/plugins
        install -m 755 dsa-check-raid-3ware $(CURDIR)/debian/dsa-nagios-nrpe-config/usr/lib/nagios/plugins
        install -m 755 dsa-check-da-in-aliases $(CURDIR)/debian/dsa-nagios-nrpe-config/usr/lib/nagios/plugins
diff --git a/dsa-nagios-nrpe-config/dsa-check-raid-mpt b/dsa-nagios-nrpe-config/dsa-check-raid-mpt
new file mode 100755 (executable)
index 0000000..5dd1155
--- /dev/null
@@ -0,0 +1,70 @@
+#!/usr/bin/perl -Tw
+
+# Copyright (C) 2008 Peter Palfrader <peter@palfrader.org>
+
+# Need to allow /usr/local/bin/tw_cli info c0 u0 status in sudoers:
+#
+#  nagios          ALL=(ALL) NOPASSWD: /usr/sbin/mpt-status -s
+#
+
+use strict;
+use English;
+use Getopt::Long;
+
+$ENV{'PATH'} = '/bin:/sbin:/usr/bin:/usr/sbin';
+delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
+
+my $MPT_STATUS = '/usr/sbin/mpt-status';
+
+# nagios exit codes
+my $UNKNOWN = -1;
+my $OK = 0;
+my $WARNING = 1;
+my $CRITICAL = 2;
+
+$SIG{'__DIE__'} = sub {
+       print STDERR @_;
+       exit $UNKNOWN;
+};
+
+unless (-e $MPT_STATUS) {
+       print "Cannot find '$MPT_STATUS'.\n";
+       exit $UNKNOWN;
+};
+
+my $command = "sudo $MPT_STATUS -s";
+open (MPT, "$command|") or die ("Cannot run $command: $!\n");
+my @tw=<MPT>;
+close MPT;
+if ($CHILD_ERROR) { # program failed
+       die("$command returned with non-zero exit code: ".($CHILD_ERROR / 256)."\n");
+};
+
+
+my $exit = $UNKNOWN;
+my $msg = '';
+for my $line (@tw)  {
+       chomp $line;
+       next if $line =~ /^$/;
+       my ($device, $num, $status) = $line =~ m#^(vol_id|phys_id)\s+([0-9]+)\s+(.*)$#;
+       unless (defined($device) && defined($num) && defined($status)) {
+               print "Cannot parse line '$line'\n";
+               exit $UNKNOWN;
+       };
+       if ($status eq 'OPTIMAL' ||
+           $status eq 'ONLINE') {
+               $msg .= ($msg eq '' ? '' : '; '). "$device $num: $status";
+               $exit = $exit > $OK ? $exit : $OK;
+       } else {
+               $msg .= ($msg eq '' ? '' : '; '). "$device $num: $status";
+               $exit = $exit > $CRITICAL ? $exit : $CRITICAL;
+       };
+};
+
+if ($msg eq '') {
+       $msg = "No devices found";
+       die ("exit is not UNKNOWN but $exit") if ($exit != $UNKNOWN);
+}
+
+print $msg,"\n";
+exit $exit;
index 7903356..1c9971c 100644 (file)
@@ -1129,6 +1129,12 @@ services:
     servicegroups: raid
     nrpe: "/usr/lib/nagios/plugins/dsa-check-raid-3ware"
     hosts: puccini
+ ###
+  -
+    name: RAID - MPT
+    servicegroups: raid
+    nrpe: "/usr/lib/nagios/plugins/dsa-check-raid-mpt"
+    hosts: master
 
  ###
   -