From 911aac86b511ed206f3980d327058ce229a77d2e Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Thu, 10 Aug 2006 12:15:29 +0000 Subject: Implement --version git-svn-id: svn+ssh://asteria.noreply.org/svn/weaselutils/trunk@174 bc3d92e2-beff-0310-a7cd-cc87d7ac0ede --- nagios-check-printer-supplies | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'nagios-check-printer-supplies') diff --git a/nagios-check-printer-supplies b/nagios-check-printer-supplies index 92b84a8..0d1abd1 100755 --- a/nagios-check-printer-supplies +++ b/nagios-check-printer-supplies @@ -2,7 +2,7 @@ # # Checks HP printers for supplies # -# Copyright (c) 2006 Peter Palfrader +# Copyright (c) 2006 Peter Palfrader # # # Based on snmp__supplies, a munin plugin for graphing supplies: @@ -60,6 +60,22 @@ my $session; +sub version($$) { + my ($fd, $exit) = @_; + print $fd "nagios-check-printer-supplies $VERSION\n"; + print $fd "Copyright (c) 2006 Peter Palfrader \n"; + print $fd "Also Copyright Rune Nordboe Skillingstad, Sveinung Marvik\n"; + exit 0 if $exit; +}; + +sub help($$) { + my ($exitcode, $fd) = @_; + version ($fd, 0); + print $fd "Usage: $PROGRAM_NAME --version\n"; + print $fd "Usage: $PROGRAM_NAME [--verbose [--verbose ..]] [--community ] [--timeout ] [--port ] [--critical ] [--warning ] --host \n"; + exit $exitcode +}; + sub record($$) { my ($newexit, $msg) = @_; @@ -71,13 +87,6 @@ sub record($$) { push @{$MESSAGE->{$newexit}}, $msg } -sub help($$) { - my ($exitcode, $fd) = @_; - print $fd "Usage: $PROGRAM_NAME --version\n"; - print $fd "Usage: $PROGRAM_NAME [--verbose [--verbose ..]] [--community ] [--timeout ] [--port ] [--critical ] [--warning ] --host \n"; - exit $exitcode -}; - sub get_multiple($$$) { my $handle = shift; my $oid = shift; @@ -131,6 +140,7 @@ if (!GetOptions ( die ("$PROGRAM_NAME: Usage: $PROGRAM_NAME [-fwhv]\n"); }; +version(*STDOUT, 1) if $params->{'version'}; help(0, *STDOUT) if $params->{'help'}; help(1, *STDERR) unless defined $params->{'host'}; help(1, *STDERR) if scalar @ARGV > 0; -- cgit v1.2.3