salvage), check_bos now reports a warning stating that, rather than a
critical error showing the auxiliary status line. Reported by Steve
Rader.
+
+ Print an UNKNOWN status on standard output on syntax errors in all
+ scripts, rather than reporting the problem only to standard error.
+ Check that the host to check was specified and report a syntax error
+ if it wasn't. Thanks, Tobias Wolter.
# Implementation
##############################################################################
+# Report a syntax error and exit. We do this via stdout in order to satisfy
+# the Nagios plugin output requirements, but also report a more conventional
+# error via stderr in case people are calling this outside of Nagios.
+sub syntax {
+ print "AFS UNKNOWN - ", join ('', @_), "\n";
+ warn "$0: ", join ('', @_), "\n";
+ exit 3;
+}
+
# Parse command line options.
my ($help, $host, $version);
Getopt::Long::config ('bundling', 'no_ignore_case');
'h|help' => \$help,
't|timeout=i' => \$TIMEOUT,
'V|version' => \$version,
- 'w|warning=i' => \$WARNINGS) or exit 3;
+ 'w|warning=i' => \$WARNINGS)
+ or syntax ("invalid option");
if ($help) {
print "Feeding myself to perldoc, please wait....\n";
exec ('perldoc', '-t', $0) or die "Cannot fork: $!\n";
print "check_afsspace $version\n";
exit 0;
}
-if (@ARGV) {
- warn "Usage: $0 [-hv] [-c <level>] [-w <level>] -H <host>\n";
- exit 3;
-}
+syntax ("extra arguments on command line") if @ARGV;
+syntax ("host to check not specified") unless (defined $host);
if ($WARNINGS > $CRITICAL) {
- warn "$0: warning level $WARNINGS greater than critical level $CRITICAL\n";
- exit 3;
+ syntax ("warning level $WARNINGS greater than critical level $CRITICAL");
}
# Set up the alarm.
# Implementation
##############################################################################
+# Report a syntax error and exit. We do this via stdout in order to satisfy
+# the Nagios plugin output requirements, but also report a more conventional
+# error via stderr in case people are calling this outside of Nagios.
+sub syntax {
+ print "BOS UNKNOWN - ", join ('', @_), "\n";
+ warn "$0: ", join ('', @_), "\n";
+ exit 3;
+}
+
# Parse command line options.
my ($help, $host, $version);
Getopt::Long::config ('bundling', 'no_ignore_case');
GetOptions ('H|hostname=s' => \$host,
'h|help' => \$help,
't|timeout=i' => \$TIMEOUT,
- 'V|version' => \$version) or exit 3;
+ 'V|version' => \$version)
+ or syntax ("invalid option");
if ($help) {
print "Feeding myself to perldoc, please wait....\n";
exec ('perldoc', '-t', $0) or die "Cannot fork: $!\n";
print "check_bos $version\n";
exit 0;
}
-if (@ARGV) {
- print "Usage: $0 [-hv] [-t <timeout>] -H <host>\n";
- warn "Usage: $0 [-hv] [-t <timeout>] -H <host>\n";
- exit 3;
-}
+syntax ("extra arguments on command line") if @ARGV;
+syntax ("host to check not specified") unless (defined $host);
# Set up the alarm.
$SIG{ALRM} = sub {
# Implementation
##############################################################################
+# Report a syntax error and exit. We do this via stdout in order to satisfy
+# the Nagios plugin output requirements, but also report a more conventional
+# error via stderr in case people are calling this outside of Nagios.
+sub syntax {
+ print "AFS UNKNOWN - ", join ('', @_), "\n";
+ warn "$0: ", join ('', @_), "\n";
+ exit 3;
+}
+
# Parse command line options.
my ($help, $host, $version);
Getopt::Long::config ('bundling', 'no_ignore_case');
'h|help' => \$help,
't|timeout=i' => \$TIMEOUT,
'V|version' => \$version,
- 'w|warning=i' => \$WARNINGS) or exit 3;
+ 'w|warning=i' => \$WARNINGS)
+ or syntax ("invalid option");
if ($help) {
print "Feeding myself to perldoc, please wait....\n";
exec ('perldoc', '-t', $0) or die "Cannot fork: $!\n";
print "check_rxdebug $version\n";
exit 0;
}
-if (@ARGV) {
- warn "Usage: $0 [-hv] [-c <level>] [-w <level>] -H <host>\n";
- exit 3;
-}
+syntax ("extra arguments on command line") if @ARGV;
+syntax ("host to check not specified") unless (defined $host);
if ($WARNINGS > $CRITICAL) {
- warn "$0: warning level $WARNINGS greater than critical level $CRITICAL\n";
- exit 3;
+ syntax ("warning level $WARNINGS greater than critical level $CRITICAL");
}
# Set up the alarm.
# Implementation
##############################################################################
+# Report a syntax error and exit. We do this via stdout in order to satisfy
+# the Nagios plugin output requirements, but also report a more conventional
+# error via stderr in case people are calling this outside of Nagios.
+sub syntax {
+ print "UBIK UNKNOWN - ", join ('', @_), "\n";
+ warn "$0: ", join ('', @_), "\n";
+ exit 3;
+}
+
# Parse command line options.
my ($help, $host, $port, $version);
Getopt::Long::config ('bundling', 'no_ignore_case');
'h|help' => \$help,
'p|port=i' => \$port,
't|timeout=i' => \$TIMEOUT,
- 'V|version' => \$version) or exit 3;
+ 'V|version' => \$version)
+ or syntax ("invalid option");
if ($help) {
print "Feeding myself to perldoc, please wait....\n";
exec ('perldoc', '-t', $0) or die "Cannot fork: $!\n";
print "check_udebug $version\n";
exit 0;
}
-if (@ARGV || !(defined ($host) && defined ($port))) {
- warn "Usage: $0 [-hv] [-t <timeout>] -H <host> -p <port>\n";
- exit 3;
-}
+syntax ("extra arguments on command line") if @ARGV;
+syntax ("host to check not specified") unless (defined $host);
+syntax ("port to check not specified") unless (defined $port);
# Set up the alarm.
$SIG{ALRM} = sub {