summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2006-08-10 12:15:29 +0000
committerweasel <weasel@bc3d92e2-beff-0310-a7cd-cc87d7ac0ede>2006-08-10 12:15:29 +0000
commit911aac86b511ed206f3980d327058ce229a77d2e (patch)
tree32835102deef657686a858035154016eaf0c3510
parente3559d2997ddb4a22a4eab7403c6fbdbef1fb709 (diff)
Implement --version
git-svn-id: svn+ssh://asteria.noreply.org/svn/weaselutils/trunk@174 bc3d92e2-beff-0310-a7cd-cc87d7ac0ede
-rwxr-xr-xnagios-check-printer-supplies26
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;