packages: nagios-plugin-check_raid/check_raid - without /bin/sh, perlish st...

glen glen at pld-linux.org
Wed Sep 9 18:28:32 CEST 2009


Author: glen                         Date: Wed Sep  9 16:28:32 2009 GMT
Module: packages                      Tag: HEAD
---- Log message:
- without /bin/sh, perlish style: check_ips (unchecked)

---- Files affected:
packages/nagios-plugin-check_raid:
   check_raid (1.15 -> 1.16) 

---- Diffs:

================================================================
Index: packages/nagios-plugin-check_raid/check_raid
diff -u packages/nagios-plugin-check_raid/check_raid:1.15 packages/nagios-plugin-check_raid/check_raid:1.16
--- packages/nagios-plugin-check_raid/check_raid:1.15	Wed Sep  9 18:26:37 2009
+++ packages/nagios-plugin-check_raid/check_raid	Wed Sep  9 18:28:27 2009
@@ -193,28 +193,26 @@
 }
 
 sub check_ips {
-	my($l, at f);
-	my($s,$n,$c);
+	my @CMD = $ipssend;
+	unshift(@CMD, $sudo) if $> and $sudo;
 
-	my $CMD = "$ipssend getconfig 1 LD";
-	$CMD = "$sudo $CMD" if $> and $sudo;
+	my $n;
+	open(my $fh , '-|', @CMD) or return;
+	while (<$fh>) {
+		chomp;
+		if (/drive number (\d+)/i ) { $n = $1; next; }
+		next unless valid($n);
 
-	open IPS,"$CMD |" or return;
-	while( $l = <IPS> ) {
-		chomp $l;
-		if( $l =~ /drive number (\d+)/i ) { $n = $1; next; }
-		next if(!valid($n));
-		if( $l =~ /Status .*: (\S+)\s+(\S+)/ ) {
-			($s,$c) = ($1,$2);
-			if( $c =~ /SYN|RBL/i ) { # resynching
-				$status = $ERRORS{WARNING} if(!$status);
-			} elsif( $c !~ /OKY/i ) { # not OK
+		if (my($s, $c) = /Status .*: (\S+)\s+(\S+)/ ) {
+			if ($c =~ /SYN|RBL/i ) { # resynching
+				$status = $ERRORS{WARNING} unless $status;
+			} elsif ($c !~ /OKY/i) { # not OK
 				$status = $ERRORS{CRITICAL};
 			}
 			$message .= "ips:$n:$s ";
 		}
 	}
-	close IPS;
+	close $fh;
 }
 
 sub check_aaccli {
================================================================

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



More information about the pld-cvs-commit mailing list