version 1.27, 2009/11/09 22:51:44 |
version 1.28, 2009/11/09 22:58:41 |
|
|
#!/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.27 2009/11/09 22:51:44 andrew Exp $ |
######################################################################## |
######################################################################## |
# check_hw_sensors *** A nagios check for OpenBSD sysctl hw.sensors |
# check_hw_sensors *** A nagios check for OpenBSD sysctl hw.sensors |
# |
# |
|
|
|
|
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, |
|
|
} |
} |
|
|
if ($opt_h |
if ($opt_h |
|| ( ( !defined $filename ) && ( !defined $sensor ) ) |
|| ( ( !defined $filename ) |
|
&& ( !defined $sensor ) |
|
&& ( !defined $ignore_status ) ) |
|
|
#|| ( defined $sensor && !( $warning || $critical ) ) |
#|| ( defined $sensor && !( $warning || $critical ) ) |
) |
) |
|
|
$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'}; |
} |
} |