[packages/nagios-plugin-check_megaraid_sas] Rel 7
arekm
arekm at pld-linux.org
Sun Mar 29 01:15:39 CET 2026
commit b67be4ce7d749e39c55cfe4d170a9a6e812ad4ef
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Sun Mar 29 01:15:25 2026 +0100
Rel 7
bbu.patch | 238 +++++++++++++++++-----------------
nagios-plugin-check_megaraid_sas.spec | 4 +-
2 files changed, 122 insertions(+), 120 deletions(-)
---
diff --git a/nagios-plugin-check_megaraid_sas.spec b/nagios-plugin-check_megaraid_sas.spec
index f35d86f..c5ec262 100644
--- a/nagios-plugin-check_megaraid_sas.spec
+++ b/nagios-plugin-check_megaraid_sas.spec
@@ -3,7 +3,7 @@ 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: 6
+Release: 7
License: GPL v2
Group: Networking
# http://exchange.nagios.org/components/com_mtree/attachment.php?link_id=680&cf_id=24
@@ -35,7 +35,7 @@ controller supported by the MegaCli tool.
install %{SOURCE0} %{plugin}
%{__sed} -i -e 's#/usr/sbin/MegaCli#/sbin/MegaCli#g' %{plugin}
-%patch -P0 -p0
+%patch -P0 -p1
%patch -P1 -p1
%patch -P2 -p1
diff --git a/bbu.patch b/bbu.patch
index bc85c5c..df0d3e5 100644
--- a/bbu.patch
+++ b/bbu.patch
@@ -1,118 +1,120 @@
---- 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
+diff -urNp -x '*.orig' nagios-plugin-check_megaraid_sas-12.org/check_megaraid_sas nagios-plugin-check_megaraid_sas-12/check_megaraid_sas
+--- nagios-plugin-check_megaraid_sas-12.org/check_megaraid_sas 2026-03-29 01:14:32.755219490 +0100
++++ nagios-plugin-check_megaraid_sas-12/check_megaraid_sas 2026-03-29 01:14:32.823793982 +0100
+@@ -35,13 +35,14 @@ use Getopt::Std;
+ 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 $othererrors = 0;
+ my $otherallow = 0;
+ my $result = '';
+ my $status = 'OK';
++my $checkbbu = 0;
+
+ sub max_state ($$) {
+ my ($current, $compare) = @_;
+@@ -103,6 +105,9 @@ if ( $opt_p ) {
+ 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 @@ while (<ADPCOUNT>) {
+ 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 @@ ADAPTER: for ( my $adp = 0; $adp < $adap
+ # 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 @@ ADAPTER: for ( my $adp = 0; $adp < $adap
+ $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 @@ ADAPTER: for ( my $adp = 0; $adp < $adap
+ }
+ }
+
+- $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;
+
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/nagios-plugin-check_megaraid_sas.git/commitdiff/b67be4ce7d749e39c55cfe4d170a9a6e812ad4ef
More information about the pld-cvs-commit
mailing list