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.
47 lines
697 B
Perl
47 lines
697 B
Perl
#!/usr/bin/perl
|
|
|
|
%Monitors = (
|
|
"Power Overload" => 1,
|
|
"Main Power Fault" => 1,
|
|
"Power Control Fault" => 1,
|
|
"Drive Fault" => 1,
|
|
"Cooling/Fan Fault" => 1
|
|
);
|
|
|
|
open(I, "/dev/ipmi0") or &unknown("Unable to open IPMI device");
|
|
close I;
|
|
|
|
open(I, "ipmitool -I open chassis status|") or &unknown("Unable to run IPMI command");
|
|
|
|
$code = 0;
|
|
while (<I>) {
|
|
chop;
|
|
s/ *: /:/;
|
|
($mon, $state) = split /:/;
|
|
if ($Monitors{$mon} and $state ne "false") {
|
|
push @result, $mon;
|
|
$code = 2;
|
|
}
|
|
}
|
|
|
|
close I;
|
|
|
|
if ($code == 0) {
|
|
print "OK: no chassis faults\n";
|
|
exit 0;
|
|
}
|
|
|
|
else {
|
|
$result = join ", ", @result;
|
|
print "CRITICAL: $result\n";
|
|
exit $code;
|
|
}
|
|
|
|
|
|
sub unknown
|
|
{
|
|
print "UNKNOWN: @_[0]\n";
|
|
exit 3;
|
|
}
|
|
|