Author: glen                         Date: Wed Sep  9 16:35:23 2009 GMT
Module: packages                      Tag: HEAD
---- Log message:
- perlish check_lsraid, check_metastat (unchecked)

---- Files affected:
packages/nagios-plugin-check_raid:
   check_raid (1.17 -> 1.18) 

---- Diffs:

================================================================
Index: packages/nagios-plugin-check_raid/check_raid
diff -u packages/nagios-plugin-check_raid/check_raid:1.17 
packages/nagios-plugin-check_raid/check_raid:1.18
--- packages/nagios-plugin-check_raid/check_raid:1.17   Wed Sep  9 18:31:24 2009
+++ packages/nagios-plugin-check_raid/check_raid        Wed Sep  9 18:35:18 2009
@@ -61,24 +61,25 @@
        foreach ( @ignore ) { return 0 if((lc $_) eq $v); }
        return 1;
 }
+
 #####################################################################
 sub check_metastat {
        my($l,$s,$d,$sd);
 
-       my $CMD = $metastat;
-       $CMD = "$sudo $CMD" if $> and $sudo;
+       my @CMD = $metastat;
+       unshift(@CMD, $sudo) if $> and $sudo;
 
-       open METASTAT,"$CMD |" or return;
-       while( $l = <METASTAT> ) {
-               chomp $l;
-               if($l =~ /^(\S+):/) { $d = $1; $sd = ''; next; }
-               if($l =~ /Submirror \d+:\s+(\S+)/) { $sd = $1; next; }
-               if($l =~ /State: (\S.+)/) { $s = $1;
-                       if($sd and valid($sd) and valid($d)) {
-                               if($s =~ /Okay/i) {
+       open(my $fh , '-|', @CMD) or return;
+       while (<$fh>) {
+               chomp;
+               if (/^(\S+):/) { $d = $1; $sd = ''; next; }
+               if (/Submirror \d+:\s+(\S+)/) { $sd = $1; next; }
+               if (my($s) = /State: (\S.+)/) {
+                       if ($sd and valid($sd) and valid($d)) {
+                               if ($s =~ /Okay/i) {
                                        # no worries...
-                               } elsif($s =~ /Resync/i) {
-                                       $status = $ERRORS{WARNING} if(!$status);
+                               } elsif ($s =~ /Resync/i) {
+                                       $status = $ERRORS{WARNING} unless 
$status;
                                } else {
                                        $status = $ERRORS{ERROR};
                                }
@@ -86,8 +87,9 @@
                        }
                }
        }
-       close METASTAT;
+       close $fh;
 }
+
 sub check_megaide {
        my $fh;
        foreach my $f (glob('/proc/megaide/*/status')) {
@@ -132,10 +134,8 @@
        }
        close $fh;
 }
-sub check_lsraid {
-       my($l);
-       my($s,$n,$f);
 
+sub check_lsraid {
        my @CMD = ($lsraid, '-A', '-p');
        unshift(@CMD, $sudo) if $> and $sudo;
 
@@ -271,16 +271,15 @@
 
        open(my $fh , '-|', @CMD) or return;
        while (<$fh>) {
-               next if(! /vol_id\s*(\d+).*state\s+(\S+),/ );
-               ($dsk,$stat) = ($1,$2);
-               next if(!valid($dsk));
+               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/) {
-                       $status = $ERRORS{CRITICAL} ;
-               } elsif(!$status and $stat !~ /ONLINE/) {
-                       $status = $ERRORS{UNKNOWN} ;
+               if (!$status and $stat =~ /INITIAL|INACTIVE|RESYNC/) {
+                       $status = $ERRORS{WARNING};
+               } elsif ($stat =~ /DEGRADED/) {
+                       $status = $ERRORS{CRITICAL};
+               } elsif (!$status and $stat !~ /ONLINE/) {
+                       $status = $ERRORS{UNKNOWN};
                }
        }
        close $fh;
================================================================

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

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

Reply via email to