| version 1.8, 2009/11/09 18:11:33 |
version 1.10, 2009/11/12 18:54:38 |
|
|
| #!/usr/bin/perl -T |
#!/usr/bin/perl -T |
| # $RedRiver: check_bioctl,v 1.7 2009/11/09 18:00:09 andrew Exp $ |
# $RedRiver: check_bioctl,v 1.9 2009/11/09 20:22:43 andrew Exp $ |
| ######################################################################## |
######################################################################## |
| # check_bioctl *** A nagios check for OpenBSD bioctl |
# check_bioctl *** A nagios check for OpenBSD bioctl |
| # |
# |
| # 2006.07.26 #*#*# andrew fresh <andrew@mad-techies.org> |
# 2006.07.26 #*#*# andrew fresh <andrew@afresh1.com> |
| ######################################################################## |
######################################################################## |
| use strict; |
use strict; |
| use warnings; |
use warnings; |
|
|
| |
|
| use constant NAGIOS_OUTPUT => 1; |
use constant NAGIOS_OUTPUT => 1; |
| |
|
| use POSIX; |
my $License = <<'EOL'; |
| use lib "/usr/local/libexec/nagios"; |
Copyright (c) 2009 Andrew Fresh <andrew@afresh1.com> |
| use utils qw($TIMEOUT %ERRORS &print_revision &support); |
Permission to use, copy, modify, and distribute this software for any |
| |
purpose with or without fee is hereby granted, provided that the above |
| |
copyright notice and this permission notice appear in all copies. |
| |
|
| use Getopt::Long; |
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| Getopt::Long::Configure('bundling'); |
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| |
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| |
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| |
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| |
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| |
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| |
EOL |
| |
|
| my $PROGNAME = "check_bioctl"; |
my $PROGNAME = "check_bioctl"; |
| my $BIOCTL = '/sbin/bioctl'; |
my $BIOCTL = '/sbin/bioctl'; |
| |
|
| |
use POSIX; |
| |
my $PREFIX; |
| |
BEGIN { |
| |
## no critic 'warnings' |
| |
no warnings 'uninitialized'; |
| |
$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'); |
| |
|
| # This maps the status we get from bioctl to something nagios can use |
# This maps the status we get from bioctl to something nagios can use |
| my %Status_Map = ( |
my %Status_Map = ( |
| Online => 'OK', |
Online => 'OK', |
|
|
| exit $ERRORS{$state}; |
exit $ERRORS{$state}; |
| |
|
| sub print_help { |
sub print_help { |
| print <<EOL; |
print <<"EOL"; |
| $PROGNAME plugin for Nagios monitors bioctl on OpenBSD |
$PROGNAME plugin for Nagios monitors bioctl on OpenBSD |
| $PROGNAME -d <device> [ -d <device2> [ -d ... ] ] |
$PROGNAME -d <device> [ -d <device2> [ -d ... ] ] |
| |
|
|
|
| EOL |
EOL |
| |
|
| print_revision( $PROGNAME, '$Revision$' ); |
print_revision( $PROGNAME, '$Revision$' ); |
| |
|
| |
print $License; |
| } |
} |
| |
|
| |
|
| |
sub print_revision { |
| |
my ($prog, $rev) = @_; |
| |
$rev =~ s/^\D+([\d\.]+)\D+$/v$1/xms; |
| |
|
| |
print "$prog $rev\n"; |
| |
} |