Code

*** empty log message ***
[nagiosplug.git] / contrib / check_linux_raid.pl
index 44f166b15dde38f87cf67b916a06ebee47443d09..2a58dbe0e8e8e2ab4f3f4bdcebed060eb09f32b6 100644 (file)
@@ -26,6 +26,12 @@ use strict;
 
 my %ERRORS=('DEPENDENT'=>4,'UNKNOWN'=>3,'OK'=>0,'WARNING'=>1,'CRITICAL'=>2);
 
+# die with an error if we're not on Linux
+if ($^O ne 'linux') {
+    print "This plugin only applicable on Linux.\n";
+    exit $ERRORS{'UNKNOWN'};
+}
+
 open (MDSTAT, "</proc/mdstat") or die "Failed to open /proc/mdstat";
 my $found = 0;
 my $status = "";
@@ -36,12 +42,14 @@ while(<MDSTAT>) {
     if ($found) {
         if (/(\[[_U]+\])/) {
             $status = $1;
-        } elsif (/recovery = (.*?)\s/) {  
+            last;
+    } elsif (/recovery = (.*?)\s/) {  
             $recovery = $1;
             ($finish) = /finish=(.*?min)/;
+           last;
         }
     } else {
-        if (/$ARGV[0]/) {
+        if (/^$ARGV[0]\s*:/) {
             $found = 1;
             if (/active/) {
                 $active = 1;