From: Peter Palfrader Date: Tue, 23 Dec 2008 22:15:06 +0000 (+0000) Subject: [project @ peter@palfrader.org-20081223221506-aubd2clif447znox] X-Git-Url: https://git.adam-barratt.org.uk/?a=commitdiff_plain;h=90b4ec88060f041ba20a061b770f3d64e5029417;p=mirror%2Fdsa-nagios.git [project @ peter@palfrader.org-20081223221506-aubd2clif447znox] dsa-check-mirrorsync: print help if additional args are given (we don't support any) --- diff --git a/dsa-nagios-nrpe-config/debian/changelog b/dsa-nagios-nrpe-config/debian/changelog index 8d8b0f5..f80153e 100644 --- a/dsa-nagios-nrpe-config/debian/changelog +++ b/dsa-nagios-nrpe-config/debian/changelog @@ -1,3 +1,10 @@ +dsa-nagios-nrpe-config (63) unstable; urgency=low + + * dsa-check-mirrorsync: print help if additional args are given (we don't + support any) + + -- Peter Palfrader Tue, 23 Dec 2008 22:14:44 +0000 + dsa-nagios-nrpe-config (62) unstable; urgency=low * Add check_securitymirror by formorer. diff --git a/dsa-nagios-nrpe-config/dsa-check-mirrorsync b/dsa-nagios-nrpe-config/dsa-check-mirrorsync index 4b318e0..413f6a1 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; +my $VERSION = '0.1'; +my $PROG = basename($PROGRAM_NAME); + +sub usage($$) { + my ($fh, $exit) = @_; + + print $fh "$PROG $VERSION\n"; + print $fh "Usage: $PROG [--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'};