[project @ peter@palfrader.org-20080424193843-b2x3gvnxqe378ae8]
authorPeter Palfrader <peter@palfrader.org>
Thu, 24 Apr 2008 19:38:43 +0000 (19:38 +0000)
committerPeter Palfrader <peter@palfrader.org>
Thu, 24 Apr 2008 19:38:43 +0000 (19:38 +0000)
A raid check for puccini

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

index 7ce96e7..57055c2 100644 (file)
@@ -1,3 +1,9 @@
+dsa-nagios-nrpe-config (34) unstable; urgency=low
+
+  * dsa-check-raid-3ware
+
+ -- Peter Palfrader <weasel@debian.org>  Thu, 24 Apr 2008 19:37:47 +0000
+
 dsa-nagios-nrpe-config (33) unstable; urgency=low
 
   * Add dsa-check-raid-dac960
index 47cb89b..59e2523 100644 (file)
@@ -17,3 +17,8 @@ dsa-check-dabackup:
   Copyright: 2007 Stephen Gran
   Copyright: 2008 Peter Palfrader
   License: MIT
+
+########################################################################
+dsa-check-raid-3ware
+  Copyright: 2006 Peter Palfrader
+  License: MIT
index 1ab4ab4..4e774a5 100755 (executable)
@@ -16,6 +16,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-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
        install -m 755 dsa-check-dabackup $(CURDIR)/debian/dsa-nagios-nrpe-config/usr/lib/nagios/plugins
        install -m 755 dsa-check-udldap-freshness $(CURDIR)/debian/dsa-nagios-nrpe-config/usr/lib/nagios/plugins
diff --git a/dsa-nagios-nrpe-config/dsa-check-raid-3ware b/dsa-nagios-nrpe-config/dsa-check-raid-3ware
new file mode 100755 (executable)
index 0000000..a9887b9
--- /dev/null
@@ -0,0 +1,111 @@
+#!/usr/bin/perl -Tw
+
+# Copyright (C) 2006 Peter Palfrader <peter@palfrader.org>
+
+# Need to allow /usr/local/bin/tw_cli info c0 u0 status in sudoers:
+#
+#  nagios          ALL=(ALL) NOPASSWD: /usr/local/bin/tw_cli info c0 u0 status
+#
+
+use strict;
+use English;
+use Getopt::Long;
+
+$ENV{'PATH'} = '/bin:/sbin:/usr/bin:/usr/sbin';
+delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
+
+my $TW_CLI = '/usr/local/bin/tw_cli';
+my $SVN_REVISION_STRING = '$Rev: 313 $';
+my ($SVN_REVISION) = ($SVN_REVISION_STRING =~ /([0-9]+)/);
+    $SVN_REVISION  = 'unknown' unless defined $SVN_REVISION;
+my $VERSION = '0.0.0.'.$SVN_REVISION;
+
+# nagios exit codes
+my $UNKNOWN = -1;
+my $OK = 0;
+my $WARNING = 1;
+my $CRITICAL = 2;
+
+my $params = {
+       'no-sudo'    => 0,
+       'controller' => 0,
+       'unit'       => 0
+       };
+
+Getopt::Long::config('bundling');
+if (!GetOptions (
+       '--help'                => \$params->{'help'},
+       '--version'             => \$params->{'version'},
+       '--verbose'             => \$params->{'verbose'},
+       '--controller=i'        => \$params->{'controller'},
+       '--unit=i'              => \$params->{'unit'},
+       '--no-sudo'             => \$params->{'no-sudo'},
+       )) {
+       die ("$PROGRAM_NAME: Usage: $PROGRAM_NAME [--help|--version] [--verbose] [--no-sudo] [--controller=<n>] [--unit=<n>]\n");
+};
+if ($params->{'help'}) {
+       print "$PROGRAM_NAME: Usage: $PROGRAM_NAME [--help|--version] [--verbose] [--no-sudo] [--controller=<n>] [--unit=<n>]\n";
+       print "Checks status of 3ware raid arrays.\n";
+       exit (0);
+};
+if ($params->{'version'}) {
+       print "nagios-check-raid-3ware $VERSION\n";
+       print "nagios check for 3ware raids\n";
+       print "Copyright (c) 2006 Peter Palfrader <peter\@palfrader.org>\n";
+       exit (0);
+};
+
+$SIG{'__DIE__'} = sub {
+       print STDERR @_;
+       exit $UNKNOWN;
+};
+
+unless (-e $TW_CLI) {
+       print "Cannot find '$TW_CLI'.\n";
+       exit $UNKNOWN;
+};
+
+my $sudo = $params->{'no-sudo'} ? '' : 'sudo ';
+my $command = "$sudo $TW_CLI info c$params->{'controller'} u$params->{'unit'} status";
+print STDERR "Running $command\n" if $params->{'verbose'};
+open (TW, "$command|") or die ("Cannot run $command: $!\n");
+my @tw=<TW>;
+close TW;
+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, $status) = $line =~ m#^(/c[0-9]+/u[0-9]+) status = ([A-Z]+)$#;
+       unless (defined($device) && defined($status)) {
+               print "Cannot parse line '$line'\n";
+               exit $UNKNOWN;
+       };
+       if ($status eq 'OK' ||
+           $status eq 'VERIFYING') {
+               $msg .= ($msg eq '' ? '' : '; '). "$device: $status";
+               $exit = $exit > $OK ? $exit : $OK;
+       } elsif ($status eq 'DEGRADED') {
+               $msg .= ($msg eq '' ? '' : '; '). "$device: $status";
+               $exit = $exit > $CRITICAL ? $exit : $CRITICAL;
+       } elsif ($status eq 'OFFLINE') {
+               $msg .= ($msg eq '' ? '' : '; '). "$device: $status";
+               $exit = $exit > $CRITICAL ? $exit : $CRITICAL;
+       } else {
+               $msg .= ($msg eq '' ? '' : '; '). "$device: UNKNOWN STATUS '$status'";
+               $exit = $exit > $UNKNOWN ? $exit : $UNKNOWN;
+       };
+};
+
+if ($msg eq '') {
+       $msg = "No devices found";
+       die ("exit is not UNKNOWN but $exit") if ($exit != $UNKNOWN);
+}
+
+print $msg,"\n";
+exit $exit;
index 2273e09..3b5ffbe 100644 (file)
@@ -1092,6 +1092,12 @@ services:
     servicegroups: raid
     nrpe: "/usr/lib/nagios/plugins/dsa-check-raid-dac960"
     hosts: verdi
+ ###
+  -
+    name: RAID - 3ware
+    servicegroups: raid
+    nrpe: "/usr/lib/nagios/plugins/dsa-check-raid-3ware"
+    hosts: puccini
 
  ###
   -