packages: nagios-plugin-check_raid/check_raid, nagios-plugin-check_raid/nag...

glen glen at pld-linux.org
Wed Apr 14 09:15:06 CEST 2010


Author: glen                         Date: Wed Apr 14 07:15:06 2010 GMT
Module: packages                      Tag: HEAD
---- Log message:
- blind code for MegaCli support

---- Files affected:
packages/nagios-plugin-check_raid:
   check_raid (1.76 -> 1.77) , nagios-plugin-check_raid.spec (1.21 -> 1.22) 

---- Diffs:

================================================================
Index: packages/nagios-plugin-check_raid/check_raid
diff -u packages/nagios-plugin-check_raid/check_raid:1.76 packages/nagios-plugin-check_raid/check_raid:1.77
--- packages/nagios-plugin-check_raid/check_raid:1.76	Tue Apr 13 12:03:31 2010
+++ packages/nagios-plugin-check_raid/check_raid	Wed Apr 14 09:15:01 2010
@@ -32,6 +32,7 @@
 # - Linux MegaIDE hardware RAID controllers via /proc/megaide
 # - Linux MPT hardware RAID via mpt-status
 # - Linux software RAID (md) via /proc/mdstat
+# - LSI Logic MegaRAID SAS series via MegaCli
 # - LSI MegaRaid via lsraid
 # - Serveraid IPS via ipssend
 # - Solaris software RAID via metastat
@@ -66,6 +67,7 @@
 my $aaccli = which('aaccli');
 my $afacli = which('afacli');
 my $lsraid = which('lsraid');
+my $megacli = which('MegaCli64') || which('MegaCli');
 my $metastat = which('metastat');
 my $lsvg = which('lsvg');
 my $ipssend = which('ipssend');
@@ -245,6 +247,48 @@
 	close $fh;
 }
 
+# Linux, software RAID
+# MegaRAID SAS 8xxx controllers
+# based on info from here:
+# http://www.bxtra.net/Articles/2008-09-16/Dell-Perc6i-RAID-Monitoring-Script-using-MegaCli-LSI-CentOS-52-64-bits
+# TODO: http://www.techno-obscura.com/~delgado/code/check_megaraid_sas
+sub check_megacli {
+	my @CMD = ($megacli, '-PDList', '-aALL');
+	unshift(@CMD, $sudo) if $> and $sudo;
+
+	open(my $fh , '-|', @CMD) or return;
+	my (@status, @devs, %cur);
+	while (<$fh>) {
+		if (my($s) = /Device Id: (\S+)/) {
+			push(@devs, { %cur }) if %cur;
+			%cur = ( dev => $s, state => undef, name => undef );
+			next;
+		}
+		if (my($s) = /Firmware state: (\S+)/) {
+			$cur{state} = $s;
+			next;
+		}
+		if (my($s) = /Inquiry Data: (.+)/) {
+			# trim some spaces
+			$s =~ s/\s+/ /g; $s =~ s/^\s+|\s+$//g;
+			$cur{name} = $s;
+			next;
+		}
+	}
+	close $fh;
+	push(@devs, { %cur }) if %cur;
+
+	foreach my $dev (@devs) {
+		push(@status, sprintf "Dev%02d (%s): %s", $dev->{dev}, $dev->{name}, $dev->{state});
+		if ($dev->{state} ne 'Online') {
+			# TODO: process other statuses
+			$status = $ERRORS{CRITICAL};
+		}
+	}
+
+	$message .= "MegaCli:".join(', ', @status) if @status;
+}
+
 # AIX LVM
 sub check_lsvg {
 	my @CMD = $lsvg;
@@ -1025,6 +1069,7 @@
 	push(@sudo, "CHECK_RAID ALL=(root) NOPASSWD: $megarc -dispCfg -a* -nolog\n") if $megarc;
 	push(@sudo, "CHECK_RAID ALL=(root) NOPASSWD: $cmdtool2 -AdpAllInfo -aALL -nolog\n") if $cmdtool2;
 	push(@sudo, "CHECK_RAID ALL=(root) NOPASSWD: $cmdtool2 -CfgDsply -a* -nolog\n") if $cmdtool2;
+	push(@sudo, "CHECK_RAID ALL=(root) NOPASSWD: $megacli -PDList -aALL\n") if $megacli;
 	foreach my $mr (</proc/mega*/*/raiddrives*>) {
 		push(@sudo, "CHECK_RAID ALL=(root) NOPASSWD: $cat $mr\n") if -d $mr;
 	}
@@ -1135,6 +1180,7 @@
 check_aaccli if -d "/proc/scsi/aacraid";
 check_afacli if $afacli;
 check_lsraid if $lsraid;
+check_megacli if $megacli;
 check_metastat if $metastat;
 check_lsvg if $lsvg;
 check_ipssend if $ipssend;

================================================================
Index: packages/nagios-plugin-check_raid/nagios-plugin-check_raid.spec
diff -u packages/nagios-plugin-check_raid/nagios-plugin-check_raid.spec:1.21 packages/nagios-plugin-check_raid/nagios-plugin-check_raid.spec:1.22
--- packages/nagios-plugin-check_raid/nagios-plugin-check_raid.spec:1.21	Tue Apr 13 11:12:43 2010
+++ packages/nagios-plugin-check_raid/nagios-plugin-check_raid.spec	Wed Apr 14 09:15:01 2010
@@ -17,6 +17,7 @@
 Suggests:	CmdTool2
 Suggests:	arcconf
 Suggests:	cciss_vol_status
+Suggests:	megacli-sas
 Suggests:	megarc-scsi
 Suggests:	mpt-status
 Suggests:	tw_cli-9xxx
@@ -75,6 +76,9 @@
 All persons listed below can be reached at <cvs_login>@pld-linux.org
 
 $Log$
+Revision 1.22  2010/04/14 07:15:01  glen
+- blind code for MegaCli support
+
 Revision 1.21  2010/04/13 09:12:43  glen
 - linux md updates, shows now resync status; rel 11
 
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/nagios-plugin-check_raid/check_raid?r1=1.76&r2=1.77&f=u
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/nagios-plugin-check_raid/nagios-plugin-check_raid.spec?r1=1.21&r2=1.22&f=u



More information about the pld-cvs-commit mailing list