=================================================================== RCS file: /cvs/nagios/check_hw_sensors/check_hw_sensors,v retrieving revision 1.20 retrieving revision 1.25 diff -u -r1.20 -r1.25 --- nagios/check_hw_sensors/check_hw_sensors 2006/12/05 00:17:47 1.20 +++ nagios/check_hw_sensors/check_hw_sensors 2008/03/10 17:21:53 1.25 @@ -1,5 +1,5 @@ #!/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.24 2007/02/14 21:59:10 andrew Exp $ ######################################################################## # check_hw_sensors *** A nagios check for OpenBSD hw.sensors # @@ -7,6 +7,7 @@ ######################################################################## # TODO: # Really need real documentation. +# allow checking of hw.sensors on a remote host with ssh somehow ######################################################################## use strict; use warnings; @@ -117,7 +118,7 @@ } if ($opt_V) { - print_revision($PROGNAME,'$Revision: 1.20 $ '); + print_revision($PROGNAME,'$Revision: 1.25 $ '); exit $ERRORS{'OK'}; } @@ -153,6 +154,7 @@ #while (<>) { chomp; my ($id, $output) = split /=/; + my @s = split /\./, $id; my @o = split /,\s*/, $output; my ($type, $source, $descr, $data, $status); @@ -160,7 +162,14 @@ $source = $o[0]; $descr = $o[1]; - if ($OSVer >= 4.0) { + if ($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]; $status = $o[3]; foreach my $t (@Type_Map) { @@ -321,7 +330,9 @@ $result = 'OK'; foreach my $code ('warn', 'crit') { if ( + $sensor->{'type'} eq 'fan' || $sensor->{'type'} eq 'fanrpm' || + $sensor->{'type'} eq 'volt' || $sensor->{'type'} eq 'volts_dc' || $sensor->{'type'} eq 'amps' || $sensor->{'type'} eq 'watthour' || @@ -469,7 +480,7 @@ $sensor->{'type'} eq 'drive' || $sensor->{'type'} eq 'indicator' ) { - $sensor->{'type'} =~ s/^drive\s+//; + $sensor->{'data'} =~ s/^drive\s+//; if (@{ $check->{$code} }) { my $matched = 0; foreach (@{ $check->{$code} }) { @@ -556,6 +567,6 @@ EOL - print_revision($PROGNAME, '$Revision: 1.20 $'); + print_revision($PROGNAME, '$Revision: 1.25 $'); }