packages: nagios-plugin-check_raid/check_raid - update from http://www.moni...

glen glen at pld-linux.org
Wed Sep 9 16:09:42 CEST 2009


Author: glen                         Date: Wed Sep  9 14:09:42 2009 GMT
Module: packages                      Tag: HEAD
---- Log message:
- update from http://www.monitoringexchange.org/cgi-bin/jump.cgi?ID=1692&view=File2;d=1
  (http://www.monitoringexchange.org/cgi-bin/page.cgi?g=Detailed/1692.html;d=1)

---- Files affected:
packages/nagios-plugin-check_raid:
   check_raid (1.2 -> 1.3) 

---- Diffs:

================================================================
Index: packages/nagios-plugin-check_raid/check_raid
diff -u packages/nagios-plugin-check_raid/check_raid:1.2 packages/nagios-plugin-check_raid/check_raid:1.3
--- packages/nagios-plugin-check_raid/check_raid:1.2	Wed Sep  9 16:03:41 2009
+++ packages/nagios-plugin-check_raid/check_raid	Wed Sep  9 16:09:37 2009
@@ -22,6 +22,7 @@
 my($VERSION) = "2.0";
 my($message, $status);
 my(@ignore);
+my($SUDO) = "/usr/bin/sudo";
 
 #####################################################################
 sub print_usage () {
@@ -77,7 +78,7 @@
 
 	foreach $f ( glob('/proc/megaide/*/status') ) {
 		if( -r $f ) { $CMD = "<$f"; }
-		else { $CMD = "sudo cat $f |"; }
+		else { $CMD = "$SUDO cat $f |"; }
 		open MEGAIDE,$CMD or next;
 		while( $l = <MEGAIDE> ) {
 			if( $l =~ /Status\s*:\s*(\S+).*Logical Drive.*:\s*(\d+)/i ) {
@@ -120,7 +121,8 @@
 	my($l);
 	my($s,$n,$f);
 
-	open LSRAID,"/sbin/lsraid -A -p |" or return;
+	return if(! -x "/sbin/lsraid");
+	open LSRAID,"/sbin/lsraid -A -p 2>/dev/null |" or return;
 	while( $l = <LSRAID> ) {
 		chomp $l;
 		if( $l =~ /\/dev\/(\S+) \S+ (\S+)/ ) {
@@ -140,12 +142,13 @@
 	my($l, at f);
 	my($s,$n,$f);
 
-	open LSVG,"/usr/sbin/lsvg |" or return;
+	return if(! -x "/usr/sbin/lsvg");
+	open LSVG,"/usr/sbin/lsvg 2>/dev/null |" or return;
 	while( $l = <LSVG> ) { chomp $l; push @vg, $l; }
 	close LSVG;
 	foreach $vg ( @vg ) {
 		next if(!valid($vg)); # skip entire VG
-		open LSVG,"/usr/sbin/lsvg -l $vg |" or return;
+		open LSVG,"/usr/sbin/lsvg -l $vg 2>/dev/null |" or return;
 		while( $l = <LSVG> ) { 
 			@f = split " ",$l;
 			($n,$s) = ($f[0],$f[5]);
@@ -165,8 +168,12 @@
 	my($s,$n,$c);
 	my($CMD);
 
-	$CMD = "/usr/local/bin/ipssend getconfig 1 LD";
-	$CMD = "sudo $CMD" if( $> );
+	$CMD = "/usr/local/nrpe/ipssend";
+	$CMD = "/usr/local/bin/ipssend" if(-f "/usr/local/bin/ipssend");
+	$CMD = "/usr/bin/ipssend" if(-f "/usr/bin/ipssend");
+	return if(! -f $CMD);
+	$CMD .= " getconfig 1 LD";
+	$CMD = "$SUDO $CMD" if( $> );
 
 	open IPS,"$CMD |" or return;
 	while( $l = <IPS> ) { 
@@ -175,7 +182,7 @@
 		next if(!valid($n));	
 		if( $l =~ /Status .*: (\S+)\s+(\S+)/ ) {
 			($s,$c) = ($1,$2);
-			if( $c =~ /SYN/i ) { # resynching
+			if( $c =~ /SYN|RBL/i ) { # resynching
 				$status = $ERRORS{WARNING} if(!$status);
 			} elsif( $c !~ /OKY/i ) { # not OK
 				$status = $ERRORS{CRITICAL};
@@ -185,6 +192,110 @@
 	}
 	close IPS;
 }
+sub check_aaccli {
+	my($dsk,$stat);
+	my($aaccli)="";
+	$aaccli = "/usr/local/nrpe/aaccli" if(-f "/usr/local/nrpe/aaccli");
+	$aaccli = "/usr/local/bin/aaccli" if(-f "/usr/local/bin/aaccli");
+	$aaccli = "/usr/sbin/aaccli" if(-f "/usr/sbin/aaccli");
+	chdir "/tmp";
+	if(!$aaccli) { $message .= "aaccli:not_installed "; return; }
+	open AACCLI,"|$SUDO $aaccli >/dev/null 2>&1";
+	print AACCLI "open aac0\n";
+	print AACCLI "logfile start $$.log\n";
+	print AACCLI "container list /full\n";
+	print AACCLI "logfile end\n";
+	print AACCLI "exit\n";
+	close AACCLI;
+#File foo receiving all output.
+#
+#AAC0>
+#COMMAND: container list /full=TRUE
+#Executing: container list /full=TRUE
+#Num          Total  Oth Stripe          Scsi   Partition                                       Creation
+#Label Type   Size   Ctr Size   Usage   C:ID:L Offset:Size   State   RO Lk Task    Done%  Ent Date   Time
+#----- ------ ------ --- ------ ------- ------ ------------- ------- -- -- ------- ------ --- ------ --------
+# 0    Mirror 74.5GB            Open    0:02:0 64.0KB:74.5GB Normal                        0  051006 13:48:54
+# /dev/sda             Auth             0:03:0 64.0KB:74.5GB Normal                        1  051006 13:48:54
+#
+#
+#AAC0>
+#COMMAND: logfile end
+#Executing: logfile end
+	open STAT,"<$$.log";
+	while ( <STAT> ) {
+		if( /(\d:\d\d?:\d+)\s+\S+:\S+\s+(\S+)/ ) {
+			($dsk,$stat) = ($1,$2);
+			next if(!valid($dsk));
+			$dsk =~ s/:/\//g;
+			next if(!valid($dsk));
+			$message .= "aac:$dsk:$stat ";
+			$status = $ERRORS{CRITICAL} if($stat eq "Broken");
+			$status = $ERRORS{WARNING} if(!$status and $stat eq "Rebuild");
+			$status = $ERRORS{WARNING} if(!$status and $stat eq "Bld/Vfy");
+			$status = $ERRORS{CRITICAL} if($stat eq "Missing");
+			$status = $ERRORS{WARNING} if(!$status and $stat eq "Verify");
+			$status = $ERRORS{WARNING} if(!$status and $stat eq "VfyRepl");
+		}
+	}
+	close STAT;
+	unlink "$$.log";
+}
+sub check_afacli {
+	$message .= "afacli:not_supported ";
+}
+sub check_mpt {
+	my($cmd) = "/usr/local/nrpe/mpt-status";
+	my($dsk,$stat);
+
+	$cmd = "/usr/local/bin/mpt-status" if(-f "/usr/local/bin/mpt-status");
+	$cmd = "/usr/bin/mpt-status" if(-f "/usr/bin/mpt-status");
+	return if(! -f $cmd);
+
+	open CMD,"$SUDO $cmd|" or return;	
+	while ( <CMD> ) {
+		next if(! /vol_id\s*(\d+).*state\s+(\S+),/ );
+		($dsk,$stat) = ($1,$2);
+		next if(!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} ;
+		}
+	}
+	close CMD;
+}
+sub check_megaraid { 
+	my($f,$l);
+	my($s,$n);
+	my($CMD);
+
+	foreach $f ( glob('/proc/megaraid/*/raiddrives*') ) {
+		if( -r $f ) { $CMD = "<$f"; }
+		else { $CMD = "$SUDO /bin/cat $f |"; }
+		open MEGARAID,$CMD or next;
+		while( $l = <MEGARAID> ) {
+			if( $l =~ /logical drive\s*:\s*(\d+).*, state\s*:\s*(\S+)/i ) {
+				($n,$s)=($1,$2);
+				next if(!valid($n));
+				if($s ne 'optimal') {
+					$status = $ERRORS{CRITICAL};
+					$message .= "Megaraid:$n:$s ";
+				} else {
+					$message .= "Megaraid:$n:$s ";
+				}
+				last;
+			}
+		}
+		close MEGARAID;
+	}
+}
+
+
+###########################################################################
 sub sudoers {
 	my($f);
 
@@ -196,8 +307,13 @@
 	print "Updating file $f\n";
 	open SUDOERS, ">>$f";
 	print SUDOERS "ALL  ALL=(root) NOPASSWD:/usr/local/bin/ipssend getconfig 1 LD\n" if( -f "/usr/local/bin/ipssend" );
+	print SUDOERS "ALL  ALL=(root) NOPASSWD:/usr/local/bin/aaccli container list /full\n" if( -f "/usr/local/bin/aaccli" );
 	print SUDOERS "ALL  ALL=(root) NOPASSWD:/bin/cat /proc/megaide/0/status\n" if( -d "/proc/megaide/0" );
 	print SUDOERS "ALL  ALL=(root) NOPASSWD:/bin/cat /proc/megaide/1/status\n" if( -d "/proc/megaide/1" );
+	print SUDOERS "ALL  ALL=(root) NOPASSWD:/usr/local/bin/mpt-status\n" if( -d "/proc/mpt" );
+	foreach my $mr ( glob('/proc/mega*/*/raiddrives*') ) {
+		print SUDOERS "ALL  ALL=(root) NOPASSWD:/bin/cat $mr\n" if( -d $mr );
+	}
 
 	close SUDOERS;
 	print "sudoers file updated.\n";
@@ -232,12 +348,19 @@
 
 $status = $ERRORS{OK}; $message = '';
 
-check_megaide if( -d "/proc/megaide" ); # Linux, hardware RAID
-check_mdstat  if( -f "/proc/mdstat" ); # Linux, software RAID
-check_lsraid  if( -x "/sbin/lsraid" ); #  Linux, software RAID
-check_metastat if( -x "/usr/sbin/metastat" ); # Solaris, software RAID
-check_vg      if( -x "/usr/sbin/lsvg" ); # AIX LVM
-check_ips     if( -x "/usr/local/bin/ipssend"  ); # Serveraid
+check_megaide if( -d "/proc/megaide" );           # MegaIDE RAID controller
+check_mdstat  if( -f "/proc/mdstat" );            # Linux LVM 
+check_mpt     if( -d "/proc/mpt"  );              # LSILogic MPT ServeRAID 
+check_megaraid if( -d "/proc/megaraid"  );        # MegaRAID
+check_aaccli  if( -d "/proc/scsi/aacraid"  );     # Adaptec ServeRAID
+check_lsraid  if( -x "/sbin/lsraid" );            # Linux, software RAID
+check_metastat if( -x "/usr/sbin/metastat" );     # Solaris, software RAID
+check_vg      if( -x "/usr/sbin/lsvg" );          # AIX LVM
+check_ips     if( -x "/usr/local/bin/ipssend"
+					or -x "/usr/bin/ipssend"  );  # Serveraid IPS
+check_afacli  if( -x "/usr/local/bin/afacli" 
+					or -x "/usr/bin/afacli" );    # Adaptec RAID
+# Cant do megaRAID controller, it needs X and java (yuck)
 
 if( $message ) {
 	if( $status == $ERRORS{OK} ) {
================================================================

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



More information about the pld-cvs-commit mailing list