diff options
author | Peter Palfrader <peter@palfrader.org> | 2006-08-10 12:15:29 +0000 |
---|---|---|
committer | weasel <weasel@bc3d92e2-beff-0310-a7cd-cc87d7ac0ede> | 2006-08-10 12:15:29 +0000 |
commit | 911aac86b511ed206f3980d327058ce229a77d2e (patch) | |
tree | 32835102deef657686a858035154016eaf0c3510 | |
parent | e3559d2997ddb4a22a4eab7403c6fbdbef1fb709 (diff) |
Implement --version
git-svn-id: svn+ssh://asteria.noreply.org/svn/weaselutils/trunk@174 bc3d92e2-beff-0310-a7cd-cc87d7ac0ede
-rwxr-xr-x | nagios-check-printer-supplies | 26 |
1 files changed, 18 insertions, 8 deletions
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 <peter@palfrader.org> # # # 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 <peter\@palfrader.org>\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 <community>] [--timeout <timeout>] [--port <port>] [--critical <critical>] [--warning <warning>] --host <hostname>\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 <community>] [--timeout <timeout>] [--port <port>] [--critical <critical>] [--warning <warning>] --host <hostname>\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; |