From e58155ec3e7428265f8ba5bb223c33440ede356f Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Tue, 22 Jul 2008 23:17:15 +0200 Subject: [PATCH] [project @ peter@palfrader.org-20080722211715-69dsek1e30flwd1j] dsa-check-hpacucli: Check transfer speed of disks --- dsa-nagios-nrpe-config/debian/changelog | 6 +++ dsa-nagios-nrpe-config/debian/postinst | 5 +++ dsa-nagios-nrpe-config/dsa-check-hpacucli | 50 +++++++++++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/dsa-nagios-nrpe-config/debian/changelog b/dsa-nagios-nrpe-config/debian/changelog index b2e5f2f..aabb758 100644 --- a/dsa-nagios-nrpe-config/debian/changelog +++ b/dsa-nagios-nrpe-config/debian/changelog @@ -1,3 +1,9 @@ +dsa-nagios-nrpe-config (47) unstable; urgency=low + + * dsa-check-hpacucli: Check transfer speed of disks. + + -- Peter Palfrader Tue, 22 Jul 2008 23:14:50 +0200 + dsa-nagios-nrpe-config (46) unstable; urgency=low * Move apt status update from cron.daily to usr/sbin/dsa-update-apt-status. diff --git a/dsa-nagios-nrpe-config/debian/postinst b/dsa-nagios-nrpe-config/debian/postinst index 391e31b..2173952 100644 --- a/dsa-nagios-nrpe-config/debian/postinst +++ b/dsa-nagios-nrpe-config/debian/postinst @@ -53,8 +53,13 @@ if [ -e /usr/sbin/hpacucli ] && [ -e /dev/cciss/c0d0 ] ; then echo 'WARNIG: Add these lines to sudoers:' echo 'nagios ALL=(ALL) NOPASSWD: /usr/sbin/hpacucli controller all show' echo 'nagios ALL=(ALL) NOPASSWD: /usr/sbin/hpacucli controller slot=0 pd all show' + echo 'nagios ALL=(ALL) NOPASSWD: /usr/sbin/hpacucli controller slot=0 pd [0-9]\:[0-9] show' + echo 'nagios ALL=(ALL) NOPASSWD: /usr/sbin/hpacucli controller slot=0 pd [0-9]I\:[0-9]\:[0-9] show' echo 'nagios ALL=(ALL) NOPASSWD: /usr/sbin/hpacucli controller slot=0 show status' echo + elif ! grep '^nagios.*hpacucli.* pd .*:.* show' /etc/sudoers > /dev/null; then + echo 'nagios ALL=(ALL) NOPASSWD: /usr/sbin/hpacucli controller slot=0 pd [0-9]\:[0-9] show' + echo 'nagios ALL=(ALL) NOPASSWD: /usr/sbin/hpacucli controller slot=0 pd [0-9]I\:[0-9]\:[0-9] show' fi fi diff --git a/dsa-nagios-nrpe-config/dsa-check-hpacucli b/dsa-nagios-nrpe-config/dsa-check-hpacucli index 1fd74e6..2bc260a 100755 --- a/dsa-nagios-nrpe-config/dsa-check-hpacucli +++ b/dsa-nagios-nrpe-config/dsa-check-hpacucli @@ -84,6 +84,7 @@ my @resultstr; for my $slot (sort @controllers) { my $pds = runcmd("controller slot=$slot pd all show"); + my @drives; my $nodrives = 0; my %status; for (@$pds) { @@ -106,11 +107,60 @@ for my $slot (sort @controllers) { } else { record('UNKNOWN'); }; + push @drives, $drive; } else { die ("Cannot read line '$_' gotten from hpacucli controller slot=$slot pd all show\n"); }; }; + # Check that all drives have the proper transfer speed. + # sometimes stuff breaks and they fall back to 10mb/sec. + for my $drive (@drives) { + my $type; + if ($drive =~ /^[0-9]+:[0-9]+$/) { # scsi drives + $type = 'SCSI'; + } elsif ($drive =~ /^[0-9]+I:[0-9]+:[0-9]+$/) { # SAS + $type = 'SAS'; + } else { + # I'm not going to run pass arguments of unknown form to the shell.. + warn ("Unknown diskdrive ID $drive\n"); + next; + } + + my $pd = runcmd("controller slot=$slot pd $drive show"); + while (defined $pd->[0] && !($pd->[0] =~ /physicaldrive/)) { + shift @$pd; + }; + shift @$pd; + my %value; + for (@$pd) { + if (m/^\s*(.*?):\s*(.*?)\s*$/) { + $value{$1} = $2; + } + } + + my $key; + my $expected; + if ($type eq 'SCSI') { + $key = 'Transfer Speed'; + $expected = '320 MB/Sec'; + } elsif ($type eq 'SAS') { + $key = 'PHY Transfer Rate'; + $expected = '3.0GBPS'; + } else { + warn "Should not be here. Do not know what to do with type '$type'\n"; + next; + } + + if (!defined $value{$key}) { + record('WARNING'); + push @{$status{'unknown transfer speed'}}, $drive; + } elsif ($value{$key} ne $expected) { + record('WARNING'); + push @{$status{'bad transfer speed'}}, $drive."(".$value{$key}.")"; + }; + }; + if ($nodrives && scalar keys %status > 0) { push @resultstr, "Slot $slot: have no drives but status results?"; record('UNKNOWN'); -- 2.20.1