packages: nagios-plugin-check_raid/check_raid - use mpt-status -s for easie...

glen glen at pld-linux.org
Fri Sep 11 14:52:47 CEST 2009


Author: glen                         Date: Fri Sep 11 12:52:47 2009 GMT
Module: packages                      Tag: HEAD
---- Log message:
- use mpt-status -s for easier parsing (also makes sudo rule more exact)
- check also physical disks in check_mpt

---- Files affected:
packages/nagios-plugin-check_raid:
   check_raid (1.40 -> 1.41) 

---- Diffs:

================================================================
Index: packages/nagios-plugin-check_raid/check_raid
diff -u packages/nagios-plugin-check_raid/check_raid:1.40 packages/nagios-plugin-check_raid/check_raid:1.41
--- packages/nagios-plugin-check_raid/check_raid:1.40	Fri Sep 11 14:17:58 2009
+++ packages/nagios-plugin-check_raid/check_raid	Fri Sep 11 14:52:42 2009
@@ -299,23 +299,40 @@
 		return;
 	}
 
+	# status messages pushed here
+	my @status;
+
 	my @CMD = $mpt_status;
 	unshift(@CMD, $sudo) if $> and $sudo;
 
-	open(my $fh , '-|', @CMD) or return;
+	open(my $fh , '-|', @CMD, '-s') or return;
 	while (<$fh>) {
-		next unless (my($dsk, $stat) = /vol_id\s*(\d+).*state\s+(\S+),/);
-		next unless valid($dsk);
-		$message .= "mpt:$dsk:$stat ";
-		if (!$status and $stat =~ /INITIAL|INACTIVE|RESYNC/) {
-			$status = $ERRORS{WARNING};
-		} elsif ($stat =~ /DEGRADED/) {
+		if (my($d, $s) = /^log_id\s*(\d+)\s+(\S+)/) {
+			next unless valid($d);
+			if (!$status and $s =~ /INITIAL|INACTIVE|RESYNC/) {
+				$status = $ERRORS{WARNING};
+			} elsif ($s =~ /DEGRADED/) {
+				$status = $ERRORS{CRITICAL};
+			} elsif (!$status and $s !~ /ONLINE|OPTIMAL/) {
+				$status = $ERRORS{UNKNOWN};
+			}
+			push(@status, "Logical Volume $d:$s");
+			next;
+		}
+
+		if (my($d, $s) = /^phys_id\s*(\d+)\s+(\S+)/) {
+			next if ($s eq "ONLINE");
+
+			# TODO: process other statuses
 			$status = $ERRORS{CRITICAL};
-		} elsif (!$status and $stat !~ /ONLINE|OPTIMAL/) {
-			$status = $ERRORS{UNKNOWN};
+
+			push(@status, "Physical Disk $d:$s");
+			next;
 		}
 	}
 	close $fh;
+
+	$message = "mpt:".join(', ', @status) if @status;
 }
 
 sub check_megaraid {
@@ -563,7 +580,7 @@
 	push(@sudo, "CHECK_RAID ALL=(root) NOPASSWD: $ipssend getconfig 1 LD\n") if $ipssend;
 	push(@sudo, "CHECK_RAID ALL=(root) NOPASSWD: $aaccli container list /full\n") if $aaccli;
 	push(@sudo, "CHECK_RAID ALL=(root) NOPASSWD: $tw_cli info*\n") if $tw_cli;
-	push(@sudo, "CHECK_RAID ALL=(root) NOPASSWD: $mpt_status\n") if $mpt_status and -d "/proc/mpt";
+	push(@sudo, "CHECK_RAID ALL=(root) NOPASSWD: $mpt_status -s\n") if $mpt_status and -d "/proc/mpt";
 	push(@sudo, "CHECK_RAID ALL=(root) NOPASSWD: $cat /proc/megaide/0/status\n") if -d "/proc/megaide/0";
 	push(@sudo, "CHECK_RAID ALL=(root) NOPASSWD: $cat /proc/megaide/1/status\n") if -d "/proc/megaide/1";
 	push(@sudo, "CHECK_RAID ALL=(root) NOPASSWD: $arcconf GETCONFIG 1 *\n") if $arcconf;
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/nagios-plugin-check_raid/check_raid?r1=1.40&r2=1.41&f=u



More information about the pld-cvs-commit mailing list