version 1.20, 2006/12/05 00:17:47 |
version 1.24, 2007/02/14 21:59:10 |
|
|
#!/usr/bin/perl -T |
#!/usr/bin/perl -T |
# $RedRiver: check_hw_sensors,v 1.19 2006/12/04 23:33:53 andrew Exp $ |
# $RedRiver: check_hw_sensors,v 1.23 2007/01/22 02:38:35 andrew Exp $ |
######################################################################## |
######################################################################## |
# check_hw_sensors *** A nagios check for OpenBSD hw.sensors |
# check_hw_sensors *** A nagios check for OpenBSD hw.sensors |
# |
# |
|
|
######################################################################## |
######################################################################## |
# TODO: |
# TODO: |
# Really need real documentation. |
# Really need real documentation. |
|
# allow checking of hw.sensors on a remote host with ssh somehow |
######################################################################## |
######################################################################## |
use strict; |
use strict; |
use warnings; |
use warnings; |
|
|
#while (<>) { |
#while (<>) { |
chomp; |
chomp; |
my ($id, $output) = split /=/; |
my ($id, $output) = split /=/; |
|
my @s = split /\./, $id; |
my @o = split /,\s*/, $output; |
my @o = split /,\s*/, $output; |
|
|
my ($type, $source, $descr, $data, $status); |
my ($type, $source, $descr, $data, $status); |
|
|
$source = $o[0]; |
$source = $o[0]; |
$descr = $o[1]; |
$descr = $o[1]; |
|
|
if ($OSVer >= 4.0) { |
if (@s == 4) { # XXX This mebbe needs to end up $OSVer >= 4.1 |
|
$data = $o[0]; |
|
if ($data =~ s/\s+\((.*)\).*$//) { |
|
$descr = $1; |
|
} |
|
$status = $o[1]; |
|
($source, $type) = $id =~ /([^\.]+)\.([^\.]+)\d+$/; |
|
} elsif ($OSVer >= 4.0) { |
$data = $o[2]; |
$data = $o[2]; |
$status = $o[3]; |
$status = $o[3]; |
foreach my $t (@Type_Map) { |
foreach my $t (@Type_Map) { |
|
|
$result = 'OK'; |
$result = 'OK'; |
foreach my $code ('warn', 'crit') { |
foreach my $code ('warn', 'crit') { |
if ( |
if ( |
|
$sensor->{'type'} eq 'fan' || |
$sensor->{'type'} eq 'fanrpm' || |
$sensor->{'type'} eq 'fanrpm' || |
|
$sensor->{'type'} eq 'volt' || |
$sensor->{'type'} eq 'volts_dc' || |
$sensor->{'type'} eq 'volts_dc' || |
$sensor->{'type'} eq 'amps' || |
$sensor->{'type'} eq 'amps' || |
$sensor->{'type'} eq 'watthour' || |
$sensor->{'type'} eq 'watthour' || |
|
|
$sensor->{'type'} eq 'drive' || |
$sensor->{'type'} eq 'drive' || |
$sensor->{'type'} eq 'indicator' |
$sensor->{'type'} eq 'indicator' |
) { |
) { |
$sensor->{'type'} =~ s/^drive\s+//; |
$sensor->{'data'} =~ s/^drive\s+//; |
if (@{ $check->{$code} }) { |
if (@{ $check->{$code} }) { |
my $matched = 0; |
my $matched = 0; |
foreach (@{ $check->{$code} }) { |
foreach (@{ $check->{$code} }) { |