From 9373218c11fbfef514554b3becb4d379697a7dcf Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Wed, 7 May 2008 19:53:13 +0000 Subject: Also check controller status git-svn-id: svn+ssh://asteria.noreply.org/svn/weaselutils/trunk@346 bc3d92e2-beff-0310-a7cd-cc87d7ac0ede --- nagios-check-hpacucli | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'nagios-check-hpacucli') diff --git a/nagios-check-hpacucli b/nagios-check-hpacucli index 2104f51..26a07fe 100755 --- a/nagios-check-hpacucli +++ b/nagios-check-hpacucli @@ -90,9 +90,9 @@ for my $slot (sort @controllers) { chomp; next if /^$/; next if /^ *array [A-Z]$/; + next if (/^\S.*in Slot $slot/); if (/^Error: The specified controller does not have any physical drives on it.$/) { $nodrives = 1; - } elsif (/^\S.*in Slot $slot/) { } elsif (/^ *physicaldrive (\S+) .* (OK|Predictive Failure|Failed)(?:, spare)?\)$/) { my $drive = $1; my $status = $2; @@ -113,15 +113,32 @@ for my $slot (sort @controllers) { if ($nodrives && scalar keys %status > 0) { push @resultstr, "Slot $slot: have no drives but status results?"; record('UNKNOWN'); + next; } elsif ($nodrives) { push @resultstr, "Slot $slot: no drives"; - } elsif (scalar keys %status > 0) { - push @resultstr, "Slot $slot: ".join("; ", (map { $_.": ".join(", ", @{$status{$_}}) } keys %status)); - } else { - push @resultstr, "Slot $slot: no results?"; - record('UNKNOWN'); + next; + }; + + my $cst = runcmd("controller slot=$slot show status"); + for (@$cst) { + chomp; + next if /^$/; + next if (/^\S.*in Slot $slot/); + if (/^ *(.*) Status: (.*)$/) { + my $system = $1; + my $status = $2; + push @{$status{$status}}, $system; + if ($status ne 'OK') { + record('WARNING'); + }; + } else { + die ("Cannot read line '$_' gotten from hpacucli controller slot=$slot show status\n"); + }; }; + + my $status = join("; ", (map { $_.": ".join(", ", @{$status{$_}}) } keys %status)); + push @resultstr, "Slot $slot: $status"; }; -print "$EXITCODE: ", join(";; ", @resultstr), "\n"; +print "$EXITCODE: ", join(" - ", @resultstr), "\n"; exit $CODE{$EXITCODE}; -- cgit v1.2.3