===================================================================
RCS file: /cvs/nagios/check_hw_sensors/check_hw_sensors,v
retrieving revision 1.38
retrieving revision 1.41
diff -u -r1.38 -r1.41
--- nagios/check_hw_sensors/check_hw_sensors 2009/11/11 18:08:41 1.38
+++ nagios/check_hw_sensors/check_hw_sensors 2009/11/12 18:53:52 1.41
@@ -1,5 +1,5 @@
#!/usr/bin/perl -T
-# $RedRiver: check_hw_sensors,v 1.37 2009/11/10 23:41:12 andrew Exp $
+# $RedRiver: check_hw_sensors,v 1.40 2009/11/11 18:14:40 andrew Exp $
########################################################################
# check_hw_sensors *** A nagios check for OpenBSD sysctl hw.sensors
#
@@ -27,28 +27,35 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
EOL
+my $PROGNAME = 'check_hw_sensors';
+my $SYSCTL = '/sbin/sysctl';
+my $GETCAP = '/usr/bin/getcap';
+my $BASE = 'hw.sensors';
+my $DEFAULT_CONFIG = '/etc/sensorsd.conf';
+
use POSIX;
use Config;
my $PREFIX;
+
BEGIN {
## no critic 'warnings'
no warnings 'uninitialized';
- $PREFIX = "${PREFIX}" || '/usr/local'; # Magic for OpenBSD ports tree
+ $PREFIX = "${PREFIX}" || '/usr/local'; # Magic for OpenBSD ports tree
}
use lib $PREFIX . '/libexec/nagios';
use utils qw($TIMEOUT %ERRORS &support);
+$SIG{'ALRM'} = sub {
+ print("ERROR: $PROGNAME timeout\n");
+ exit $ERRORS{'UNKNOWN'};
+};
+alarm($TIMEOUT);
+
use Getopt::Long;
Getopt::Long::Configure('bundling');
-my $PROGNAME = 'check_hw_sensors';
+my $OSVer = $Config{'osvers'} || 0;
-my $SYSCTL = '/sbin/sysctl';
-my $GETCAP = '/usr/bin/getcap';
-my $BASE = 'hw.sensors';
-my $DEFAULT_CONFIG = '/etc/sensorsd.conf';
-my $OSVer = $Config{'osvers'} || 0;
-
my $state = 'UNKNOWN'; # tells whether the it is warning, critical, or OK
my $opt_V;
my $opt_h;
@@ -75,7 +82,7 @@
}
if ($opt_V) {
- print_revision( $PROGNAME, '$Revision: 1.38 $ ' );
+ print_revision( $PROGNAME, '$Revision: 1.41 $ ' );
exit $ERRORS{'OK'};
}
@@ -160,7 +167,7 @@
print $error . ' (' . scalar( @{ $STATES{$error} } ) . ')';
if ( $error ne 'OK' ) {
print '
';
- print map { s/\s+//xms; " - $_
" } @{ $STATES{$error} };
+ print map {" - $_
"} @{ $STATES{$error} };
}
}
else {
@@ -535,7 +542,7 @@
EOL
- print_revision( $PROGNAME, '$Revision: 1.38 $' );
+ print_revision( $PROGNAME, '$Revision: 1.41 $' );
print $LICENSE;