You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Princeton/pu/libexec/check_om_pu.pl

86 lines
1.5 KiB
Perl

#!/usr/bin/perl
$cmd1 = "/usr/bin/omreport chassis -fmt ssv";
$cmd2 = "/usr/bin/omreport storage pdisk controller=0 -fmt ssv";
@st = ('OK', 'WARNING', 'CRITICAL', 'UNKNOWN');
$rc = 0;
$rs = '';
open(CMD1, "$cmd1|"); # XXX
# skip to header
while (<CMD1>) {
last if /SEVERITY/;
}
# read individual satus lines; end if blank line
while (<CMD1>) {
chop;
($status, $component) = split /;/;
last if ($status eq '') and ($component eq '');
# print "$component: $status\n";
if ($status ne 'Ok') {
$rc = 2;
$rs = $rs . " $component: $status";
}
}
close CMD1;
CTLR: for ($ctln = 0; $ctln < 3; $ctln++, close(CMD2)) {
open(CMD2, "/usr/bin/omreport storage pdisk controller=$ctln -fmt ssv |");
# skip to header
while (<CMD2>) {
chop;
next CTLR if /Invalid controller/;
if (/Status/) {
@a = split /;/;
$n = 0;
foreach $i (@a) {
$names{$i} = $n++;
}
last;
}
}
# read individual satus lines; end if blank line
while (<CMD2>) {
chop;
next CTLR if /No Physical/;
@a = split /;/;
$id = $a[$names{'ID'}];
$status = $a[$names{'Status'}];
$fp = $a[$names{'Failure Predicted'}];
last if ($id eq '') and ($status eq '');
# print "$id: $status fp = $fp\n";
if ($fp ne 'No') {
$rs = $rs . " Disk $id: Failure predicted";
$rc = 1 if $rc == 0;
}
if ($status ne 'Ok') {
$rc = 2;
$rs = $rs . " disk $id: $status";
}
}
}
$rs = ' No problems detected by Open Manage' if $rc == 0;
print "$st[$rc]:$rs\n";
exit $rc;