[packages/nagios-plugin-check_megaraid_sas] - add patch to support Battery Back Up status - rel 2
baggins
baggins at pld-linux.org
Thu Oct 11 13:29:51 CEST 2012
commit 878f656145299be0c33844b8a11fc49ba07bc126
Author: Jan Rękorajski <baggins at pld-linux.org>
Date: Thu Oct 11 13:29:16 2012 +0200
- add patch to support Battery Back Up status
- rel 2
bbu.patch | 118 ++++++++++++++++++++++++++++++++++
nagios-plugin-check_megaraid_sas.spec | 5 +-
2 files changed, 122 insertions(+), 1 deletion(-)
---
diff --git a/nagios-plugin-check_megaraid_sas.spec b/nagios-plugin-check_megaraid_sas.spec
index 89f9d9a..704319c 100644
--- a/nagios-plugin-check_megaraid_sas.spec
+++ b/nagios-plugin-check_megaraid_sas.spec
@@ -3,11 +3,12 @@ Summary: Nagios plugin to check the state of disk and logical drives attached to
Name: nagios-plugin-%{plugin}
# revision from download page
Version: 12
-Release: 1
+Release: 2
License: GPL v2
Group: Networking
# http://exchange.nagios.org/components/com_mtree/attachment.php?link_id=680&cf_id=24
Source0: check_megaraid_sas
+Patch0: bbu.patch
URL: http://exchange.nagios.org/directory/Plugins/Hardware/Storage-Systems/RAID-Controllers/check_megaraid_sas/details
Requires: megaraid-sas
Requires: nagios-core
@@ -32,6 +33,8 @@ controller supported by the MegaCli tool.
install %{SOURCE0} %{plugin}
sed -e 's#/usr/sbin/MegaCli#/sbin/MegaCli#g' %{plugin}
+%patch0 -p0
+
cat > nagios.cfg <<'EOF'
# Usage:
# %{plugin}
diff --git a/bbu.patch b/bbu.patch
new file mode 100644
index 0000000..bc85c5c
--- /dev/null
+++ b/bbu.patch
@@ -0,0 +1,118 @@
+--- check_megaraid_sas.orig 2011-04-14 13:41:43.000000000 -0400
++++ check_megaraid_sas 2011-04-14 13:37:29.959793550 -0400
+@@ -35,13 +35,14 @@
+ use lib qw(/usr/lib/nagios/plugins /usr/lib64/nagios/plugins); # possible pathes to your Nagios plugins and utils.pm
+ use utils qw(%ERRORS);
+
+-our($opt_h, $opt_s, $opt_o, $opt_m, $opt_p);
++our($opt_h, $opt_s, $opt_o, $opt_m, $opt_p, $opt_b);
+
+
+-getopts('hs:o:p:m:');
++getopts('bhs:o:p:m:');
+
+ if ( $opt_h ) {
+ print "Usage: $0 [-s number] [-m number] [-o number]\n";
++ print " -b check Battery Back Up status\n";
+ print " -s is how many hotspares are attached to the controller\n";
+ print " -m is the number of media errors to ignore\n";
+ print " -p is the predictive error count to ignore\n";
+@@ -66,6 +67,7 @@
+ my $otherallow = 0;
+ my $result = '';
+ my $status = 'OK';
++my $checkbbu = 0;
+
+ sub max_state ($$) {
+ my ($current, $compare) = @_;
+@@ -103,6 +105,9 @@
+ if ( $opt_o ) {
+ $otherallow = $opt_o;
+ }
++if ( $opt_b ) {
++ $checkbbu = $opt_b;
++}
+
+ # Some sanity checks that you actually have something where you think MegaCli is
+ (-e $megaclibin)
+@@ -121,6 +126,42 @@
+ close ADPCOUNT;
+
+ ADAPTER: for ( my $adp = 0; $adp < $adapters; $adp++ ) {
++ # Get the Battery Back Up state for this adapter
++ my ($bbustate);
++ if ($checkbbu) {
++ open (BBUGETSTATUS, "$megacli -AdpBbuCmd -GetBbuStatus -a$adp $megapostopt |")
++ || exitreport('UNKNOWN', "error: Could not execute $megacli -AdpBbuCmd -GetBbuStatus -a$adp $megapostopt");
++
++ my ($bbucharging, $bbufullycharged, $bburelativecharge, $bbuexitcode);
++ while (<BBUGETSTATUS>) {
++ # Charging Status
++ if ( m/Charging Status\s*:\s*(\w+)/i ) {
++ $bbucharging = $1;
++ } elsif ( m/Fully Charged\s*:\s*(\w+)/i ) {
++ $bbufullycharged = $1;
++ } elsif ( m/Relative State of Charge\s*:\s*(\w+)/i ) {
++ $bburelativecharge = $1;
++ } elsif ( m/Exit Code\s*:\s*(\w+)/i ) {
++ $bbuexitcode = $1;
++ }
++ }
++ close BBUGETSTATUS;
++
++ # Determine the BBU state
++ if ( $bbuexitcode ne '0x00' ) {
++ $bbustate = 'NOT FOUND';
++ $status = 'CRITICAL';
++ } elsif ( $bbucharging ne 'None' ) {
++ $bbustate = 'Charging (' . $bburelativecharge . '%)';
++ $status = 'WARNING';
++ } elsif ( $bbufullycharged ne 'Yes' ) {
++ $bbustate = 'Not Charging (' . $bburelativecharge . '%)';
++ $status = 'WARNING';
++ } else {
++ $bbustate = 'Charged (' . $bburelativecharge . '%)';
++ }
++ }
++
+ # Get the number of logical drives on this adapter
+ open (LDGETNUM, "$megacli -LdGetNum -a$adp $megapostopt |")
+ || exitreport('UNKNOWN', "error: Could not execute $megacli -LdGetNum -a$adp $megapostopt");
+@@ -138,8 +179,9 @@
+ # Get info on this particular logical drive
+ open (LDINFO, "$megacli -LdInfo -L$ld -a$adp $megapostopt |")
+ || exitreport('UNKNOWN', "error: Could not execute $megacli -LdInfo -L$ld -a$adp $megapostopt ");
+-
+- my ($size, $unit, $raidlevel, $ldpdcount, $state, $spandepth);
++
++ my $consistency_output = '';
++ my ($size, $unit, $raidlevel, $ldpdcount, $state, $spandepth, $consistency_percent, $consistency_minutes);
+ while (<LDINFO>) {
+ if ( m/Size\s*:\s*((\d+\.?\d*)\s*(MB|GB|TB))/ ) {
+ $size = $2;
+@@ -160,6 +202,9 @@
+ $spandepth = $1;
+ } elsif ( m/RAID Level\s*: Primary-(\d)/ ) {
+ $raidlevel = $1;
++ } elsif ( m/\s+Check Consistency\s+:\s+Completed\s+(\d+)%,\s+Taken\s+(\d+)\s+min/ ) {
++ $consistency_percent = $1;
++ $consistency_minutes = $2;
+ }
+ }
+ close LDINFO;
+@@ -172,8 +217,14 @@
+ }
+ }
+
+- $result .= "$adp:$ld:RAID-$raidlevel:$ldpdcount drives:$size$unit:$state ";
+-
++ if ($consistency_percent) {
++ $status = 'WARNING';
++ $consistency_output = "CC ${consistency_percent}% ${consistency_minutes}m:";
++ }
++
++ $result .= "$adp:";
++ $result .= "BBU $bbustate:" if ($checkbbu);
++ $result .= "$ld:RAID-$raidlevel:$ldpdcount drives:$size$unit:$consistency_output$state ";
+ } #LDISK
+ close LDINFO;
\ No newline at end of file
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/nagios-plugin-check_megaraid_sas.git/commitdiff/878f656145299be0c33844b8a11fc49ba07bc126
More information about the pld-cvs-commit
mailing list