[Pkg-nagios-changes] [pkg-nagios-plugins-contrib] 04/13: check_raid: Updating to latest git version (5bc04e1822)
Jan Wagner
waja at moszumanska.debian.org
Fri Mar 6 09:57:09 UTC 2015
This is an automated email from the git hooks/post-receive script.
waja pushed a commit to branch master
in repository pkg-nagios-plugins-contrib.
commit 19e12620b32290f3573dbf63c4fc961968d6f80b
Author: Jan Wagner <waja at cyconet.org>
Date: Wed Mar 4 16:25:36 2015 +0100
check_raid: Updating to latest git version (5bc04e1822)
---
check_raid/check_raid | 90 +++++++++++++++++++++++++++++++++++++++------------
check_raid/control | 2 +-
debian/control | 2 +-
3 files changed, 72 insertions(+), 22 deletions(-)
diff --git a/check_raid/check_raid b/check_raid/check_raid
index dd3d9b4..80b9128 100644
--- a/check_raid/check_raid
+++ b/check_raid/check_raid
@@ -11,7 +11,7 @@
# 2004-2006 Steve Shipway, university of auckland,
# http://www.steveshipway.org/forum/viewtopic.php?f=20&t=417&p=3211
# Steve Shipway Thanks M Carmier for megaraid section.
-# 2009-2014 Elan Ruusamäe <glen at pld-linux.org>
+# 2009-2015 Elan Ruusamäe <glen at pld-linux.org>
# Requires: Perl 5.8 for the open(my $fh , '-|', @CMD) syntax.
# You can workaround for earlier Perl it as:
@@ -56,7 +56,7 @@ use strict;
{
package utils;
-my @EXPORT = qw(which $sudo);
+my @EXPORT = qw(which find_sudo);
my @EXPORT_OK = @EXPORT;
# registered plugins
@@ -83,7 +83,24 @@ sub which {
return undef;
}
-our $sudo = which('sudo');
+our @sudo;
+sub find_sudo() {
+ # detect once
+ return \@sudo if @sudo;
+
+ my $sudo = which('sudo') or die "Can't find sudo";
+ push(@sudo, $sudo);
+
+ # detect if sudo supports -A, issue #88
+ open(my $fh , '-|', $sudo, '-h') or die "Can't run 'sudo -h': $!";
+ local $/ = undef;
+ local $_ = <$fh>;
+ close($fh) or die $!;
+ push(@sudo, '-A') if /-A/;
+
+ return \@sudo;
+}
+
} # package utils
{
@@ -138,7 +155,7 @@ sub new {
my $self = {
program_names => [ $class->program_names ],
commands => $class->commands,
- sudo => $class->sudo ? $utils::sudo : '',
+ sudo => $class->sudo ? utils::find_sudo() : '',
@_,
name => $class,
status => undef,
@@ -382,7 +399,7 @@ sub cmd {
my @CMD = $this->{program};
# add sudo if program needs
- unshift(@CMD, $this->{sudo}, '-A') if $> and $this->{sudo};
+ unshift(@CMD, @{$this->{sudo}}) if $> and $this->{sudo};
my $args = $this->{commands}{$command} or croak "command '$command' not defined";
@@ -1019,6 +1036,11 @@ sub parse_ld {
next;
}
+ if (my($s) = /Virtual Drive Type\s*:\s*(\S+)/) {
+ $ld{type} = $s;
+ next;
+ }
+
if (my($s) = /State\s*:\s*(\S+)/) {
$ld{state} = $s;
next;
@@ -1162,6 +1184,11 @@ sub check {
my @vstatus;
foreach my $vol (@{$c->{logical}}) {
+ # skip CacheCade for now. #91
+ if ($vol->{type} && $vol->{type} eq 'CacheCade') {
+ next;
+ }
+
push(@vstatus, sprintf "%s:%s", $vol->{name}, $vol->{state});
if ($vol->{state} ne 'Optimal') {
$this->critical;
@@ -1553,8 +1580,8 @@ sub program_names {
sub commands {
{
- 'status' => ['-|', '@CMD', '-i', '$id'],
'get_controller_no' => ['-|', '@CMD', '-p'],
+ 'status' => ['-|', '@CMD', '-i', '$id'],
'sync status' => ['-|', '@CMD', '-n'],
}
}
@@ -1573,10 +1600,23 @@ sub sudo {
);
}
-sub parse {
+sub active ($) {
+ my ($this) = @_;
+
+ # return if parent said NO
+ my $res = $this->SUPER::active(@_);
+ return $res unless $res;
+
+ # there should be a controller. #95
+ my $id = $this->get_controller;
+ return defined($id);
+}
+
+# get controller from mpt-status -p
+# FIXME: could there be multiple controllers?
+sub get_controller {
my $this = shift;
- my (%ld, %pd);
my $fh = $this->cmd('get_controller_no');
my $id;
while (<$fh>) {
@@ -1588,7 +1628,15 @@ sub parse {
}
close $fh;
- $fh = $this->cmd('status',{ '$id' => $id });
+ return $id;
+}
+
+sub parse {
+ my ($this, $id) = @_;
+
+ my (%ld, %pd);
+
+ my $fh = $this->cmd('status', { '$id' => $id });
my %VolumeTypesHuman = (
IS => 'RAID-0',
@@ -1684,7 +1732,8 @@ sub check {
# status messages pushed here
my @status;
- my $status = $this->parse;
+ my $id = $this->get_controller;
+ my $status = $this->parse($id);
# process logical units
while (my($d, $u) = each %{$status->{logical}}) {
@@ -2631,16 +2680,16 @@ sub parse_config {
$pd[$ch][$pd]{ncq} = $ncq;
} elsif (my($pfa) = /PFA\s+:\s+(.+)/) {
$pd[$ch][$pd]{pfa} = $pfa;
- } elsif (my($e) = /Enclosure ID\s+:\s+(.+)/) {
- $pd[$ch][$pd]{enclosure} = $e;
+ } elsif (my($eid) = /Enclosure ID\s+:\s+(.+)/) {
+ $pd[$ch][$pd]{enclosure} = $eid;
} elsif (my($t) = /Type\s+:\s+(.+)/) {
$pd[$ch][$pd]{type} = $t;
} elsif (my($smart) = /S\.M\.A\.R\.T\.(?:\s+warnings)?\s+:\s+(.+)/) {
$pd[$ch][$pd]{smart} = $smart;
} elsif (my($speed) = /Transfer Speed\s+:\s+(.+)/) {
$pd[$ch][$pd]{speed} = $speed;
- } elsif (my($l) = /Reported Location\s+:\s+(.+)/) {
- $pd[$ch][$pd]{location} = $l;
+ } elsif (my($e, $s) = /Reported Location\s+:\s+(?:Enclosure|Connector) (\d+), (?:Slot|Device) (\d+)/) {
+ $pd[$ch][$pd]{location} = "$e:$s";
} elsif (my($sps) = /Supported Power States\s+:\s+(.+)/) {
$pd[$ch][$pd]{power_states} = $sps;
} elsif (my($cd) = /Reported Channel,Device(?:\(.+\))?\s+:\s+(.+)/) {
@@ -2820,7 +2869,7 @@ sub check {
for my $pd (@{$ch}) {
# skip not disks
next if not defined $pd;
- next if $pd->{devtype} =~ 'Enclosure';
+ next if $pd->{devtype} =~ m/Enclosure/;
if ($pd->{status} eq 'Rebuilding') {
$this->resync;
@@ -2834,7 +2883,7 @@ sub check {
$this->critical;
}
- my $id = $pd->{serial} || $pd->{wwn};
+ my $id = $pd->{serial} || $pd->{wwn} || $pd->{location};
push(@{$pd{$pd->{status}}}, $id);
}
}
@@ -3792,10 +3841,11 @@ sub check {
#
# SAS2IRCU: there are no IR volumes on the controller!
# SAS2IRCU: Error executing command STATUS.
- #
- if ( /SAS2IRCU: there are no IR volumes on the controller!/ ) {
- #even though this isn't the last line, go ahead and set success.
+ if (/SAS2IRCU: there are no IR volumes on the controller/
+ or /The STATUS command is not supported by the firmware currently loaded on controller/
+ ) {
+ # even though this isn't the last line, go ahead and set success.
$success = 1;
$state = $novolsstate;
}
@@ -4459,7 +4509,7 @@ sub print_usage() {
sub print_help() {
print "check_raid, v$VERSION\n";
print "Copyright (c) 2004-2006 Steve Shipway,
-Copyright (c) 2009-2014, Elan Ruusamäe <glen\@pld-linux.org>
+Copyright (c) 2009-2015, Elan Ruusamäe <glen\@pld-linux.org>
This plugin reports the current server's RAID status
https://github.com/glensc/nagios-plugin-check_raid
diff --git a/check_raid/control b/check_raid/control
index fe6f5e7..b7a71d4 100644
--- a/check_raid/control
+++ b/check_raid/control
@@ -1,7 +1,7 @@
Homepage: https://github.com/glensc/nagios-plugin-check_raid
Watch: https://github.com/glensc/nagios-plugin-check_raid "/glensc/nagios-plugin-check_raid/tree/([0-9.]+)"
Suggests: cciss-vol-status (>= 1.10), mpt-status
-Version: 3.2.2
+Version: 3.2.2+5bc04e1822
Uploaders: Bernd Zeimetz <bzed at debian.org>
Description: plugin to check sw/hw RAID status
The plugin looks for any known types of RAID configurations,
diff --git a/debian/control b/debian/control
index 4feeb70..7a2b6c5 100644
--- a/debian/control
+++ b/debian/control
@@ -107,7 +107,7 @@ Description: Plugins for nagios compatible monitoring systems
* check_printer: plugin to check printer supply levels using SNMP
It outputs performance data for all supplies
found, for example toner and drum.
- * check_raid (3.2.2): plugin to check sw/hw RAID status
+ * check_raid (3.2.2+5bc04e1822): plugin to check sw/hw RAID status
The plugin looks for any known types of RAID configurations,
and checks them all.
.
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-nagios/pkg-nagios-plugins-contrib.git
More information about the Pkg-nagios-changes
mailing list