diff options
-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; |