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. 69
      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
next ADAPTER;
}
LDISK: for ( my $ld = 0; $ld < $ldnum; $ld++ ) { # When controller is in HBA/JBOD mode, skip RAID volume checks
# Get info on this particular logical drive unless ($hba && $failgrouplist) {
open (LDINFO, "$megacli -LdInfo -L$ld -a$adp -NoLog |") LDISK: for ( my $ld = 0; $ld < $ldnum; $ld++ ) {
|| die "error: Could not execute $megacli -LdInfo -L$ld -a$adp -NoLog"; # Get info on this particular logical drive
open (LDINFO, "$megacli -LdInfo -L$ld -a$adp -NoLog |")
my ($size, $unit, $raidlevel, $ldpdcount, $spandepth, $state); || die "error: Could not execute $megacli -LdInfo -L$ld -a$adp -NoLog";
while (<LDINFO>) {
if ( m/^Size\s*:\s*(\d+(\.\d+)?)\s*(MB|GB|TB)/ ) { my ($size, $unit, $raidlevel, $ldpdcount, $spandepth, $state);
$size = $1; while (<LDINFO>) {
$unit = $3; if ( m/^Size\s*:\s*(\d+(\.\d+)?)\s*(MB|GB|TB)/ ) {
# Adjust MB to GB if that's what we got $size = $1;
if ( $unit eq 'MB' ) { $unit = $3;
$size = sprintf( "%.0f", ($size / 1024) ); # Adjust MB to GB if that's what we got
$unit= 'GB'; if ( $unit eq 'MB' ) {
} $size = sprintf( "%.0f", ($size / 1024) );
} elsif ( m/^State\s*:\s*(\w+(\s\w+)?)/ ) { $unit= 'GB';
$state = $1; }
if ( $state ne 'Optimal' ) { } elsif ( m/^State\s*:\s*(\w+(\s\w+)?)/ ) {
$status = 'CRITICAL'; $state = $1;
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;
close LDINFO;
$result .= "$adp:$ld:RAID-$raidlevel:$ldpdcount drives:$size$unit:$state "; $result .= "$adp:$ld:RAID-$raidlevel:$ldpdcount drives:$size$unit:$state ";
} #LDISK } #LDISK
close LDINFO; 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