version 1.6, 2006/05/02 20:59:47 |
version 1.9, 2006/05/03 03:26:47 |
|
|
#!/usr/bin/perl |
#!/usr/bin/perl |
# $RedRiver: check_hw_sensors,v 1.5 2006/05/02 19:49:29 andrew Exp $ |
# $RedRiver: check_hw_sensors,v 1.8 2006/05/02 21:23:29 andrew Exp $ |
######################################################################## |
######################################################################## |
# check_hw_sensors *** A nagios check for OpenBSD hw.sensors |
# check_hw_sensors *** A nagios check for OpenBSD hw.sensors |
# |
# |
|
|
$state = $error; |
$state = $error; |
} |
} |
} |
} |
if (NAGIOS_OUTPUT && $have_results) { |
|
print '<ul>'; |
|
} |
|
foreach my $error (sort { $ERRORS{$b} <=> $ERRORS{$a} } keys %ERRORS) { |
foreach my $error (sort { $ERRORS{$b} <=> $ERRORS{$a} } keys %ERRORS) { |
if (exists $states{$error}) { |
if (exists $states{$error}) { |
if (NAGIOS_OUTPUT) { |
if (NAGIOS_OUTPUT) { |
print "<li>$error (" . scalar(@{ $states{ $error } }) . ")"; |
print "$error (" . scalar(@{ $states{ $error } }) . ")"; |
unless ($error eq 'OK') { |
unless ($error eq 'OK') { |
print '<ul>'; |
print '<br>'; |
foreach (@{ $states{ $error } }) { |
print map { " - $_<br>" } @{ $states{ $error } }; |
print "<li>$_</li>"; |
|
} |
|
print '</ul>'; |
|
} |
} |
print "</li>" |
|
} else { |
} else { |
print "$error (" . scalar(@{ $states{ $error } }) . "):\n"; |
print "$error (" . scalar(@{ $states{ $error } }) . "):\n"; |
foreach (@{ $states{ $error } }) { |
foreach (@{ $states{ $error } }) { |
|
|
if ($have_results == 0) { |
if ($have_results == 0) { |
print "No results found\n"; |
print "No results found\n"; |
} |
} |
if (NAGIOS_OUTPUT && $have_results) { |
|
print '</ul>' . "\n"; |
|
} |
|
exit $ERRORS{$state}; |
exit $ERRORS{$state}; |
|
|
|
|
|
|
$result = $errors{$code} |
$result = $errors{$code} |
if ($c <= $data); |
if ($c <= $data); |
} |
} |
} elsif (defined $check->{$code}) { |
} elsif (@{ $check->{$code} }) { |
my $matched = 0; |
my $matched = 0; |
foreach my $c (@{ $check->{$code} }) { |
foreach my $c (@{ $check->{$code} }) { |
$c =~ s/[^\d\.]//g; |
$c =~ s/[^\d\.]//g; |
unless (length $c) { |
unless (length $c) { |
warn "INVALID CHECK (" . $check->{$code} . |
warn "INVALID CHECK (" . $c . |
") for '$sensor->{'id'}:$code'"; |
") for '$sensor->{'id'}:$code'"; |
next; |
next; |
} |
} |
|
|
$result = $errors{$code} |
$result = $errors{$code} |
if ($c <= $data); |
if ($c <= $data); |
} |
} |
} elsif (defined $check->{$code}) { |
} elsif (@{ $check->{$code} }) { |
|
|
my $matched = 0; |
my $matched = 0; |
foreach my $c (@{ $check->{$code} }) { |
foreach my $c (@{ $check->{$code} }) { |
|
|
|
|
$c =~ s/[^\d\.]//g; |
$c =~ s/[^\d\.]//g; |
unless (length $c) { |
unless (length $c) { |
warn "INVALID CHECK (" . $check->{$code} . |
warn "INVALID CHECK (" . $c . |
") for '$sensor->{'id'}':$code"; |
") for '$sensor->{'id'}':$code"; |
next; |
next; |
} |
} |
|
|
$sensor->{'type'} eq 'drive' || |
$sensor->{'type'} eq 'drive' || |
$sensor->{'type'} eq 'indicator' |
$sensor->{'type'} eq 'indicator' |
) { |
) { |
if (defined $check->{$code}) { |
if (@{ $check->{$code} }) { |
my $matched = 0; |
my $matched = 0; |
foreach (@{ $check->{$code} }) { |
foreach (@{ $check->{$code} }) { |
if ($_ eq $sensor->{'data'}) { |
if ($_ eq $sensor->{'data'}) { |