Author: glen                         Date: Thu Apr  8 08:54:45 2010 GMT
Module: packages                      Tag: HEAD
---- Log message:
- improved check_mdstat by Kenneth Stailey <kstailey#yahoo.com>, original one
  failed to test for failed hot spares; all md users should upgrade :)

---- Files affected:
packages/nagios-plugin-check_raid:
   check_raid (1.72 -> 1.73) 

---- Diffs:

================================================================
Index: packages/nagios-plugin-check_raid/check_raid
diff -u packages/nagios-plugin-check_raid/check_raid:1.72 
packages/nagios-plugin-check_raid/check_raid:1.73
--- packages/nagios-plugin-check_raid/check_raid:1.72   Wed Mar 31 10:26:33 2010
+++ packages/nagios-plugin-check_raid/check_raid        Thu Apr  8 10:54:40 2010
@@ -135,30 +135,39 @@
        }
 }
 
-# Linux LVM
+# Linux Multi-Device (md)
 sub check_mdstat {
-       my($n, $f);
-
        open my $fh, '<', '/proc/mdstat' or return;
 
-       my @status;
+       my ($md, $md_units);
+       my (@status, @failed_disks);
+
        while (<$fh>) {
-               if (/^(\S+)\s+:/ ) { $n = $1; $f = ''; next; }
-               next if (($f) = /(\S+)\[\d+\]\(F\)/);
-               next unless (my($s) = /\s*.*\[([U_]+)\]/);
-               next unless valid($n);
+               if (/^(\S+)\s+:/) {
+                       $md = $1;
+                       @failed_disks = $_ =~ m/(\S+)\[\d+\]\(F\)/g;
+                       next;
+               }
+               next unless (($md_units) = /^\s+.*\[([U_]+)\]/);
+               next unless valid($md);
 
-               if ($s =~ /_/) {
+               if ($md_units =~ /_/) {
                        $status = $ERRORS{CRITICAL};
-                       push(@status, "$n:$f:$s");
+                       push(@status, "$md:@failed_disks:$md_units");
+
+               } elsif (scalar @failed_disks > 0) {
+                       $status = $ERRORS{WARNING} unless $status;
+                       push(@status, "$md:hot-spare failure: 
@failed_disks:$md_units");
+
                } else {
-                       push(@status, "$n:$s");
+                       push(@status, "$md:$md_units");
                }
        }
        close $fh;
 
        $message .= "md:[".join(', ', @status)."] " if @status;
 }
+
 
 # Linux, software RAID
 sub check_lsraid {
================================================================

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

_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to