};
}
-my $usage = "$PROGRAM_NAME: Usage: $PROGRAM_NAME [--no-battery] [--ignore-controller=<regex>] [--no-controller-ok] [--ignore-transfer-speed=<pd> [--ignore-transfer-speed=<pd> ...]]\n";
+my $usage = "$PROGRAM_NAME: Usage: $PROGRAM_NAME [--no-battery] [--ignore-cache] [--ignore-controller=<regex>] [--no-controller-ok] [--ignore-transfer-speed=<pd> [--ignore-transfer-speed=<pd> ...]]\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'},
)) {
my @drives;
my $nodrives = 0;
my %status;
+ my @freetext;
my $ldallshow = runcmd("controller slot=$slot ld all show");
my @logicaldrives;
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;
} elsif (/^Error: The specified controller does not have any physical drives on it.$/) {
$nodrives = 1;
- } elsif (/^ *physicaldrive (\S+) .* (OK|Predictive Failure|Failed|Rebuilding)(?:, (?:active )?spare)?\)$/) {
+ } elsif (/^ *physicaldrive (\S+) .* (OK|Predictive Failure|Failed|Rebuilding)(?:, (?:active )?spare.*)?\)$/) {
my $drive = $1;
my $status = $2;
push @{$status{$status}}, $drive;
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;
# - 'Permanently Disabled'
# - ...?
next if $status =~ /^(OK|Not Configured)$/;
+ if ($params->{'ignore-cache'}) {
+ push @freetext, "$system: $status (ignored)";
+ next;
+ }
}
- push @{$status{$status}}, $system;
+ push @freetext, "$system: $status";
if ($status ne 'OK') {
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";
};