X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=dsa-nagios-checks%2Fchecks%2Fdsa-check-hpssacli;h=6cae39d82290a55a5eb204b96047378ac1a93ac1;hb=2439481805151ab7cd33e668ae2b4efc931bb94a;hp=220d65b11943223f12bdcb26bf3019580134a193;hpb=dbd4865bfa744c0558043a0f186904cbd19847b6;p=mirror%2Fdsa-nagios.git diff --git a/dsa-nagios-checks/checks/dsa-check-hpssacli b/dsa-nagios-checks/checks/dsa-check-hpssacli index 220d65b..6cae39d 100755 --- a/dsa-nagios-checks/checks/dsa-check-hpssacli +++ b/dsa-nagios-checks/checks/dsa-check-hpssacli @@ -64,13 +64,14 @@ sub record($) { }; } -my $usage = "$PROGRAM_NAME: Usage: $PROGRAM_NAME [--no-battery] [--ignore-controller=] [--no-controller-ok] [--ignore-transfer-speed= [--ignore-transfer-speed= ...]]\n"; +my $usage = "$PROGRAM_NAME: Usage: $PROGRAM_NAME [--no-battery] [--ignore-cache] [--ignore-controller=] [--no-controller-ok] [--ignore-transfer-speed= [--ignore-transfer-speed= ...]]\n"; my $params; Getopt::Long::Configure('bundling'); if (!GetOptions ( '--help' => \$params->{'help'}, '--no-battery' => \$params->{'no-battery'}, '--no-controller-ok' => \$params->{'no-controller-ok'}, + '--ignore-cache' => \$params->{'ignore-cache'}, '--ignore-controller=s' => \$params->{'ignore-controller'}, '--ignore-transfer-speed=s@' => \$params->{'ignore-transfer-speed'}, )) { @@ -111,6 +112,7 @@ for my $slot (sort @controllers) { my @drives; my $nodrives = 0; my %status; + my @freetext; my $ldallshow = runcmd("controller slot=$slot ld all show"); my @logicaldrives; @@ -149,6 +151,14 @@ for my $slot (sort @controllers) { record('UNKNOWN'); } } + if (/^ *LD Acceleration Method: (.*)$/) { + my $status = $1; + # can at least be "Controller Cache" or HP SSD Smart Path", both OK + if ($status eq 'All disabled') { + push @{$status{'Acceleration method'}}, "LD$logicaldrive disabled"; + record('WARNING'); + } + } } } @@ -171,6 +181,12 @@ for my $slot (sort @controllers) { next if (/^\S.*in Slot $slot/); next if /^ *array [A-Z]$/; next if /^ *unassigned/; + if (/^ *HBA Drives/) { + # HBA mode implies no logical drives, thus reset the "drives found" check and proceed with + # checking physical drives. + $nodrives = 0; + next; + } if (/^ *(array [A-Z]) \(Failed\)$/) { record('CRITICAL'); push @{$status{'Failed'}}, $1; @@ -245,7 +261,7 @@ for my $slot (sort @controllers) { } elsif ($type eq 'SAS' || $type eq 'SAS+') { $key = 'PHY Transfer Rate'; if ($value{'Interface Type'} eq 'SATA') { - $expected = [ '1.5Gbps', '3.0Gbps' ]; + $expected = [ '1.5Gbps', '3.0Gbps', '6.0Gbps' ]; } elsif ($value{'PHY Count'} eq '2') { if (defined($value{'Redundant Path(s)'})) { $expected = [ '3.0GBPS, 3.0GBPS', '6.0GBPS, 6.0GBPS', @@ -292,26 +308,45 @@ for my $slot (sort @controllers) { next; }; - my $cst = runcmd("controller slot=$slot show status"); + my $cst = runcmd("controller slot=$slot show detail"); for (@$cst) { chomp; next if /^$/; next if (/^\S.*in Slot $slot/); - if (/^ *(.*) Status: (.*)$/) { + if (/^ *(Controller|Cache|Battery\/Capacitor) Status: (.*)$/) { my $system = $1; my $status = $2; - push @{$status{$status}}, $system; + + if ($system eq 'Cache') { + # Can be: + # - 'OK' + # - 'Not Configured' (for e.g. HP SSD Smart Path) + # - 'Permanently Disabled' + # - ...? + next if $status =~ /^(OK|Not Configured)$/; + if ($params->{'ignore-cache'}) { + push @freetext, "$system: $status (ignored)"; + next; + } + } + + push @freetext, "$system: $status"; if ($status ne 'OK') { - next if ($params->{'no-battery'} && $system eq 'Cache'); next if ($params->{'no-battery'} && $system eq 'Battery/Capacitor'); record('WARNING'); }; - } else { - die ("Cannot read line '$_' gotten from hpssacli controller slot=$slot show status\n"); + } elsif (/^ *(Cache Status Details): (Cable Error)/) { + push @freetext, $2; + record('CRITICAL'); + } elsif (/^ *(Battery\/Capacitor Count): (.*)/) { + next if $params->{'no-battery'} || int($2) > 0; + push @freetext, "Battery count: $2"; + record('CRITICAL'); }; }; - my $status = join(" - ", (map { $_.": ".join(", ", @{$status{$_}}) } keys %status)); + my $status = join(" - ", ((map { $_.": ".join(", ", @{$status{$_}}) } keys %status), @freetext)); + push @resultstr, "Slot $slot: $status"; };