=================================================================== RCS file: /cvs/nagios/check_bioctl/check_bioctl,v retrieving revision 1.8 retrieving revision 1.10 diff -u -r1.8 -r1.10 --- nagios/check_bioctl/check_bioctl 2009/11/09 18:11:33 1.8 +++ nagios/check_bioctl/check_bioctl 2009/11/12 18:54:38 1.10 @@ -1,9 +1,9 @@ #!/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 # -# 2006.07.26 #*#*# andrew fresh +# 2006.07.26 #*#*# andrew fresh ######################################################################## use strict; use warnings; @@ -12,16 +12,43 @@ use constant NAGIOS_OUTPUT => 1; -use POSIX; -use lib "/usr/local/libexec/nagios"; -use utils qw($TIMEOUT %ERRORS &print_revision &support); +my $License = <<'EOL'; +Copyright (c) 2009 Andrew Fresh +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; -Getopt::Long::Configure('bundling'); +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +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 $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 my %Status_Map = ( Online => 'OK', @@ -55,7 +82,7 @@ } if ($opt_V) { - print_revision( $PROGNAME, '$Revision: 1.8 $ ' ); + print_revision( $PROGNAME, '$Revision: 1.10 $ ' ); exit $ERRORS{'OK'}; } @@ -163,7 +190,7 @@ exit $ERRORS{$state}; sub print_help { - print < [ -d [ -d ... ] ] @@ -175,6 +202,15 @@ EOL - print_revision( $PROGNAME, '$Revision: 1.8 $' ); + print_revision( $PROGNAME, '$Revision: 1.10 $' ); + + print $License; } + +sub print_revision { + my ($prog, $rev) = @_; + $rev =~ s/^\D+([\d\.]+)\D+$/v$1/xms; + + print "$prog $rev\n"; +}