--- smeserver-zabbix-agent-0.1/root/var/lib/zabbix/bin/megaraid-parser.pl.megaraid_options 2010-02-17 13:44:48.000000000 +0100 +++ smeserver-zabbix-agent-0.1/root/var/lib/zabbix/bin/megaraid-parser.pl 2010-02-17 13:45:29.000000000 +0100 @@ -34,17 +34,21 @@ use strict; use Getopt::Std; -our($opt_h, $opt_s); +our($opt_h, $opt_s, $opt_o, $opt_m, $opt_p); -getopts('hs:'); +getopts('hs:o:p:m:'); if ( $opt_h ) { - print "usage w/o hotspare: $0\n"; - print " w/ hotspare: $0 -s \n"; + print "Usage: $0 [-s number] [-m number] [-o number]\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"; + print " -o is the number of other disk errors to ignore\n"; exit; } + my $megacli = '/opt/MegaRAID/MegaCli/MegaCli'; ## Return codes for Nagios @@ -55,7 +59,12 @@ my $hotsparecount = 0; my $pdbad = 0; my $pdcount = 0; -my $pderrors = 0; +my $mediaerrors = 0; +my $mediaallow = 0; +my $prederrors = 0; +my $predallow = 0; +my $othererrors = 0; +my $otherallow = 0; my $result = ''; my $status = 'OK'; @@ -79,6 +88,15 @@ if ( $opt_s ) { $hotspares = $opt_s; } +if ( $opt_m ) { + $mediaallow = $opt_m; +} +if ( $opt_p ) { + $predallow = $opt_p; +} +if ( $opt_o ) { + $otherallow = $opt_o; +} # Get the number of RAID controllers we have open (ADPCOUNT, "$megacli -adpCount |") @@ -150,11 +168,17 @@ PDISKS: while () { if ( m/Slot Number:\s*(\d+)/ ) { $slotnumber = $1; - $pdcount++ unless ( $slotnumber == 255 ); - } elsif ( m/Error Count:\s*(\d+)/ ) { - $pderrors += $1; + # Don't care about backplane error counts + next if ( $slotnumber == 255 ); + $pdcount++; + } elsif ( m/(\w+) Error Count:\s*(\d+)/ ) { + if ( $1 eq 'Media') { + $mediaerrors += $2; + } else { + $othererrors += $2; + } } elsif ( m/Predictive Failure Count:\s*(\d+)/ ) { - $pderrors += $1; + $prederrors += $1; } elsif ( m/Firmware state:\s*(\w+)/ ) { $fwstate = $1; if ( $fwstate eq 'Hotspare' ) { @@ -177,10 +201,15 @@ $result .= "$pdbad Bad Drives "; } +my $errorcount = $mediaerrors + $prederrors + $othererrors; # Were there any errors? -if ( $pderrors ) { - $result .= "($pderrors Errors) "; - $status = max_state($status, 'WARNING'); +if ( $errorcount ) { + $result .= "($errorcount Errors) "; + if ( ( $mediaerrors > $mediaallow ) || + ( $prederrors > $predallow ) || + ( $othererrors > $otherallow ) ) { + $status = max_state($status, 'WARNING'); + } } # Do we have as many hotspares as expected (if any)