From 43fcb98b62436744e00c38efd77f52718878d1eb Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Fri, 4 Apr 2014 18:56:33 +0200 Subject: [PATCH] Add parity check for logical drives in dsa-check-hpacucli, based on patch by George Kargiotakis --- dsa-nagios-checks/checks/dsa-check-hpacucli | 55 ++++++++++++++++++++- dsa-nagios-checks/debian/changelog | 6 ++- 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/dsa-nagios-checks/checks/dsa-check-hpacucli b/dsa-nagios-checks/checks/dsa-check-hpacucli index 7f87461..e9a299e 100755 --- a/dsa-nagios-checks/checks/dsa-check-hpacucli +++ b/dsa-nagios-checks/checks/dsa-check-hpacucli @@ -108,10 +108,63 @@ if (scalar @controllers == 0) { my @resultstr; for my $slot (sort @controllers) { - my $pds = runcmd("controller slot=$slot pd all show"); my @drives; my $nodrives = 0; my %status; + + my $ldallshow = runcmd("controller slot=$slot ld all show"); + my @logicaldrives; + for (@$ldallshow) { + chomp; + next if /^$/; + next if (/^\S.*in Slot $slot/); + next if /^ *array [A-Z]$/; + if (/logicaldrive ([0-9a-z]+)/) { + push @logicaldrives, $1; + next; + } elsif (/^Error: The specified device does not have any logical drives.$/) { + $nodrives = 1; + } else { + die ("Cannot read line '$_' gotten from hpacucli controller slot = $slot logicaldrive all show\n"); + } + }; + + # check logicaldrives + for my $logicaldrive (sort @logicaldrives) { + my $lds = runcmd("controller slot=$slot ld $logicaldrive show"); + for (@$lds) { + chomp; + next if /^$/; + if (/^ *Parity Initialization Status: (Initialization Completed|Initialization Failed|Rebuilding)$/) { + my $status = $1; + if ($status eq 'Initialization Completed') { + push @{$status{'OK'}}, "Parity LD$logicaldrive"; + } elsif ($status eq 'Rebuilding') { + push @{$status{'Failed'}}, "Parity LD$logicaldrive"; + record('WARNING'); + } elsif ($status eq 'Initialization Failed') { + push @{$status{'Failed'}}, "Parity LD$logicaldrive"; + record('CRITICAL'); + } else { + record('UNKNOWN'); + } + } + } + } + + if (!$nodrives && scalar @logicaldrives == 0) { + push @resultstr, "Slot $slot: unexpectedly, found no logical drives in list."; + record('UNKNOWN'); + } elsif ($nodrives && scalar keys %status > 0) { + push @resultstr, "Slot $slot: have no logical drives but status results?"; + record('UNKNOWN'); + next; + } elsif ($nodrives) { + push @resultstr, "Slot $slot: no logical drives"; + }; + + + my $pds = runcmd("controller slot=$slot pd all show"); for (@$pds) { chomp; next if /^$/; diff --git a/dsa-nagios-checks/debian/changelog b/dsa-nagios-checks/debian/changelog index bfa95a2..896342e 100644 --- a/dsa-nagios-checks/debian/changelog +++ b/dsa-nagios-checks/debian/changelog @@ -1,8 +1,12 @@ dsa-nagios-checks (100) UNRELEASED; urgency=low + [ Peter Palfrader ] * dsa-check-running-kernel: Check from all compression tokens. - -- Peter Palfrader Mon, 31 Mar 2014 10:46:35 +0200 + [ George Kargiotakis ] + * dsa-check-hpacucli: Add Parity check for logical drives. + + -- Peter Palfrader Fri, 04 Apr 2014 18:55:33 +0200 dsa-nagios-checks (99) unstable; urgency=low -- 2.20.1