Only skip RAID volumes checks when in HBA mode, not physical disks checks

tags/zabbix-agent-addons-0.2.108-1
Daniel Berteaud 5 years ago
parent a38b7ab4b2
commit eb817e2f7b
  1. 73
      zabbix_scripts/check_raid_megaraid_sudo

@ -139,46 +139,45 @@ ADAPTER: for ( my $adp = 0; $adp < $adapters; $adp++ ) {
} }
} }
close CFGDSPLY; close CFGDSPLY;
if ( $hba && $failgrouplist ) {
# Controler is in HBA mode, skip it # When controller is in HBA/JBOD mode, skip RAID volume checks
next ADAPTER; unless ($hba && $failgrouplist) {
} LDISK: for ( my $ld = 0; $ld < $ldnum; $ld++ ) {
# Get info on this particular logical drive
LDISK: for ( my $ld = 0; $ld < $ldnum; $ld++ ) { open (LDINFO, "$megacli -LdInfo -L$ld -a$adp -NoLog |")
# Get info on this particular logical drive || die "error: Could not execute $megacli -LdInfo -L$ld -a$adp -NoLog";
open (LDINFO, "$megacli -LdInfo -L$ld -a$adp -NoLog |")
|| die "error: Could not execute $megacli -LdInfo -L$ld -a$adp -NoLog"; my ($size, $unit, $raidlevel, $ldpdcount, $spandepth, $state);
while (<LDINFO>) {
my ($size, $unit, $raidlevel, $ldpdcount, $spandepth, $state); if ( m/^Size\s*:\s*(\d+(\.\d+)?)\s*(MB|GB|TB)/ ) {
while (<LDINFO>) { $size = $1;
if ( m/^Size\s*:\s*(\d+(\.\d+)?)\s*(MB|GB|TB)/ ) { $unit = $3;
$size = $1; # Adjust MB to GB if that's what we got
$unit = $3; if ( $unit eq 'MB' ) {
# Adjust MB to GB if that's what we got $size = sprintf( "%.0f", ($size / 1024) );
if ( $unit eq 'MB' ) { $unit= 'GB';
$size = sprintf( "%.0f", ($size / 1024) ); }
$unit= 'GB'; } elsif ( m/^State\s*:\s*(\w+(\s\w+)?)/ ) {
} $state = $1;
} elsif ( m/^State\s*:\s*(\w+(\s\w+)?)/ ) { if ( $state ne 'Optimal' ) {
$state = $1; $status = 'CRITICAL';
if ( $state ne 'Optimal' ) { }
$status = 'CRITICAL'; } elsif ( m/^Number Of Drives( per span)?\s*:\s*(\d+)/ ) {
$ldpdcount = $2;
} elsif ( m/^Span Depth\s*:\s*(\d+)/ ) {
$spandepth = $1;
$ldpdcount = $ldpdcount * $spandepth;
} elsif ( m/^RAID Level\s*:\s*Primary-(\d)/ ) {
$raidlevel = $1;
} }
} elsif ( m/^Number Of Drives( per span)?\s*:\s*(\d+)/ ) {
$ldpdcount = $2;
} elsif ( m/^Span Depth\s*:\s*(\d+)/ ) {
$spandepth = $1;
$ldpdcount = $ldpdcount * $spandepth;
} elsif ( m/^RAID Level\s*:\s*Primary-(\d)/ ) {
$raidlevel = $1;
} }
} close LDINFO;
$result .= "$adp:$ld:RAID-$raidlevel:$ldpdcount drives:$size$unit:$state ";
} #LDISK
close LDINFO; close LDINFO;
}
$result .= "$adp:$ld:RAID-$raidlevel:$ldpdcount drives:$size$unit:$state ";
} #LDISK
close LDINFO;
# Get info on physical disks for this adapter # Get info on physical disks for this adapter
open (PDLIST, "$megacli -PdList -a$adp -NoLog |") open (PDLIST, "$megacli -PdList -a$adp -NoLog |")

Loading…
Cancel
Save