version 1.27, 2009/11/09 22:51:44 |
version 1.31, 2009/11/10 18:24:56 |
|
|
#!/usr/bin/perl -T |
#!/usr/bin/perl -T |
# $RedRiver: check_hw_sensors,v 1.26 2009/11/09 21:25:07 andrew Exp $ |
# $RedRiver: check_hw_sensors,v 1.30 2009/11/09 23:13:04 andrew Exp $ |
######################################################################## |
######################################################################## |
# check_hw_sensors *** A nagios check for OpenBSD sysctl hw.sensors |
# check_hw_sensors *** A nagios check for OpenBSD sysctl hw.sensors |
# |
# |
# 2006.05.01 #*#*# andrew fresh <andrew@mad-techies.org> |
# 2006.05.01 #*#*# andrew fresh <andrew@afresh1.com> |
######################################################################## |
######################################################################## |
use strict; |
use strict; |
use warnings; |
use warnings; |
|
|
|
|
my $state = 'UNKNOWN'; # tells whether the it is warning, critical, or OK |
my $state = 'UNKNOWN'; # tells whether the it is warning, critical, or OK |
my %states; # This stores the count of states; |
my %states; # This stores the count of states; |
my $filename; |
my $opt_V; |
|
my $opt_h; |
my $ignore_status; |
my $ignore_status; |
|
my $filename; |
my $sensor; |
my $sensor; |
my $warning; |
my $warning; |
my $critical; |
my $critical; |
my $opt_h; |
|
my $opt_V; |
|
|
|
my $CHECK_SENSOR = $BASE; |
my $CHECK_SENSOR = $BASE; |
my %CHECKS; |
my %CHECKS; |
|
|
my $status = GetOptions( |
my $status = GetOptions( |
"version|V" => \$opt_V, |
"version|V" => \$opt_V, |
"help|h" => \$opt_h, |
"help|h" => \$opt_h, |
"filename|f:s" => \$filename, |
|
"ignore-status|i" => \$ignore_status, |
"ignore-status|i" => \$ignore_status, |
|
"filename|f:s" => \$filename, |
"sensor|s=s" => \$sensor, |
"sensor|s=s" => \$sensor, |
"warning|w=s" => \$warning, |
"warning|w=s" => \$warning, |
"critical|c=s" => \$critical, |
"critical|c=s" => \$critical, |
|
|
exit $ERRORS{'OK'}; |
exit $ERRORS{'OK'}; |
} |
} |
|
|
if ($opt_h |
if ($opt_h) { |
|| ( ( !defined $filename ) && ( !defined $sensor ) ) |
|
|
|
#|| ( defined $sensor && !( $warning || $critical ) ) |
|
) |
|
{ |
|
print_help(); |
print_help(); |
exit $ERRORS{'OK'}; |
exit $ERRORS{'OK'}; |
} |
} |
|
|
$r = check_sensor( $SENSORS{$s}, $CHECKS{$s} ); |
$r = check_sensor( $SENSORS{$s}, $CHECKS{$s} ); |
$data = $s . '=' . $SENSORS{$s}{'output'}; |
$data = $s . '=' . $SENSORS{$s}{'output'}; |
} |
} |
elsif ( not $ignore_status ) { |
elsif ( !$ignore_status ) { |
$r = check_sensor( $SENSORS{$s} ); |
$r = check_sensor( $SENSORS{$s} ); |
$data = $s . '=' . $SENSORS{$s}{'output'}; |
$data = $s . '=' . $SENSORS{$s}{'output'}; |
} |
} |
|
|
sub print_help { |
sub print_help { |
print <<"EOL"; |
print <<"EOL"; |
$PROGNAME - monitors sysctl hw.sensors on OpenBSD |
$PROGNAME - monitors sysctl hw.sensors on OpenBSD |
$PROGNAME [-i] (-f [<FILENAME>]|(-s <hw.sensors id> [-w limit] [-c limit])) |
$PROGNAME [-i] [-f [<FILENAME>]|(-s <hw.sensors id> [-w limit] [-c limit])] |
|
|
Usage: |
Usage: |
-i, --ignore-status |
-i, --ignore-status |