#
# does _not_ check raid status. use arrayprobe for that.
-# Copyright (c) 2008,2009 Peter Palfrader <peter@palfrader.org>
+# Copyright (c) 2008,2009,2010,2011 Peter Palfrader <peter@palfrader.org>
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
my $EXITCODE = 'OK';
$SIG{'__DIE__'} = sub {
- print STDERR @_;
+ print @_;
exit $CODE{'UNKNOWN'};
};
};
}
-my $usage = "$PROGRAM_NAME: Usage: $PROGRAM_NAME [--ignore-transfer-speed=<pd> [--ignore-transfer-speed=<pd> ...]]\n";
+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 $params;
Getopt::Long::Configure('bundling');
if (!GetOptions (
'--help' => \$params->{'help'},
+ '--no-battery' => \$params->{'no-battery'},
+ '--no-controller-ok' => \$params->{'no-controller-ok'},
+ '--ignore-controller=s' => \$params->{'ignore-controller'},
'--ignore-transfer-speed=s@' => \$params->{'ignore-transfer-speed'},
)) {
die ($usage);
for (@$ctrlallshow) {
chomp;
next if /^$/;
+ next if ($params->{'ignore-controller'} && /$params->{'ignore-controller'}/);
if (/in Slot ([0-9a-z]+)/) {
push @controllers, $1;
next;
};
if (scalar @controllers == 0) {
- print "UNKNONW: No smartarray controllers found with hpacucli\n";
- exit $CODE{'UNKNOWN'}
+ if ($params->{'no-controller-ok'}) {
+ print "No smartarray controllers found with hpacucli\n";
+ exit $CODE{'OK'}
+ } else {
+ print "UNKNOWN: No smartarray controllers found with hpacucli\n";
+ exit $CODE{'UNKNOWN'}
+ }
};
my @resultstr;
if ($params->{'ignore-transfer-speed'}) {
if (grep { $drive eq $_ } @{$params->{'ignore-transfer-speed'}}) {
push @{$status{'ignored transfer speed'}}, $drive."(".$value{$key}.")";
+ next;
};
- next;
};
if (!defined $value{$key}) {
record('WARNING');
push @{$status{'unknown transfer speed'}}, $drive;
} elsif (ref($expected) eq 'ARRAY') {
- if (scalar(grep { $value{$key} eq $_ } @$expected) == 0) {
+ if (scalar(grep { uc($value{$key}) eq uc($_) } @$expected) == 0) {
record('WARNING');
push @{$status{'bad transfer speed'}}, $drive."(".$value{$key}.")";
};
- } elsif ($value{$key} ne $expected) {
+ } elsif (uc($value{$key}) ne uc($expected)) {
record('WARNING');
push @{$status{'bad transfer speed'}}, $drive."(".$value{$key}.")";
};
my $status = $2;
push @{$status{$status}}, $system;
if ($status ne 'OK') {
+ next if ($params->{'no-battery'} && $system eq 'Cache');
+ next if ($params->{'no-battery'} && $system eq 'Battery/Capacitor');
record('WARNING');
};
} else {