X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=dsa-nagios-nrpe-config%2Fdsa-check-mirrorsync;h=4637cabbe923bc2634c0001db4b23e83dabb49bf;hb=34816cfa599726fb4d7c33e02091a14b22069312;hp=4b318e01aa00a35ec379de2a15721a42eb28b48b;hpb=db33946e3fc12555921178be09633d5cc0b42ba5;p=mirror%2Fdsa-nagios.git diff --git a/dsa-nagios-nrpe-config/dsa-check-mirrorsync b/dsa-nagios-nrpe-config/dsa-check-mirrorsync index 4b318e0..4637cab 100755 --- a/dsa-nagios-nrpe-config/dsa-check-mirrorsync +++ b/dsa-nagios-nrpe-config/dsa-check-mirrorsync @@ -3,6 +3,7 @@ # nagios check for debian security sync checks # # Copyright (c) 2008 Alexander Wirt +# Copyright (c) 2009 Peter Palfrader # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -26,14 +27,32 @@ use Date::Parse; use Getopt::Long; use Date::Parse; use Date::Format; +use File::Basename; +use English; use warnings; +sub usage($$) { + my ($fh, $exit) = @_; + my $basename = basename($PROGRAM_NAME); + my $VERSION = '0.1'; + + print $fh "$basename $VERSION\n"; + print $fh "Usage: $basename [--help|--version] [--verbose]\n"; + print $fh "\n"; + print $fh " --help Print this short help.\n"; + print $fh " --version Report version number.\n"; + print $fh " --verbose Be a little verbose.\n"; + print $fh " --host hostname to check.\n"; + print $fh " --path path to tracefile.\n"; + print $fh "\n"; + exit ($exit); +}; + + $ENV{'PATH'} = '/bin:/sbin:/usr/bin:/usr/sbin'; delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'}; -my $VERSION = '0.0'; -my $PROGRAM_NAME = 'check_securitymirror'; my $params; $params->{'host'} = 'security.debian.org'; #which host to check @@ -51,21 +70,10 @@ if (!GetOptions ( '--host=s' => \$params->{'host'}, '--path=s' => \$params->{'path'}, )) { - die ("Usage: $PROGRAM_NAME [--help|--version] [--verbose]\n"); -}; - -if ($params->{'help'}) { - print "$PROGRAM_NAME $VERSION\n"; - print "Usage: $PROGRAM_NAME [--help|--version] [--verbose]\n"; - print "\n"; - print " --help Print this short help.\n"; - print " --version Report version number.\n"; - print " --verbose Be a little verbose.\n"; - print " --host hostname to check.\n"; - print " --path path to tracefile.\n"; - print "\n"; - exit (0); + usage(*STDERR,1) }; +usage(*STDOUT,0) if ($params->{'help'}); +usage(*STDERR,1) if (scalar @ARGV); my $host = $params->{'host'}; my $path = $params->{'path'};