Exploding check commands batman ...
Andreas Ericsson
ae at op5.se
Fri Jul 1 20:04:23 CEST 2005
Paul L. Allen wrote:
> Andreas Ericsson writes:
>
>> I'm working on overloading the plugins a bit to support behaviour like
>> this. It will require the arguments in the check_command definition to
>> be enclosed in quotes (due to how POSIX getopt() works), but will
>> otherwise work nicely.
>
>
> Sounds good.
>
>> I believe it's best left out of Nagios. String mangling is rather
>> expensive and error-prone. Checking if(str[0] == 0) from the command
>> executed is a fairly simple process.
>
>
> Somewhat more complex for the perl plugins since they generally use
> the strict pragma.
That's something I'm willing to live with. Most of the plugins that
would benefit to any greater extent from overloading are written in C
anyways (check_snmp, check_tcp, check_http).
> Easy for options which take string arguments and
> where the string "0" is never valid or sensible:
The string "0" and str[0] = 0 are two quite different things. The second
is just an optimized way of writing if(strlen(str) == 0).
> $opt_x ||= $opt_x_default;
> A little extra work for options which take numeric arguments and where the
> numeric value 0 is valid and sensible but some other numeric value is
> the default:
> $opt_x = $opt_x_default if ($x eq '');
> A bigger problem for numerics if you expect the plugin to cope gracefully
> if somebody manages to not pass "" as the argument for the option and the
> option is therefore unitialized:
Making them cope gracefully is exactly what I meant by making them
overloaded.
> $opt_x = $opt_x_default if (not defined($x) or $x eq '');
> or:
> $opt_x .= '' # ensure $opt_x is initialized with something
> $opt_x = $opt_x_default if ($x eq '');
> That's the price you have to pay for asking perl to do run-time checking.
> Then again, the GetOpt module shouldn't be letting you get away with
> specifying an option that requires an argument without giving an argument,
> but I'm sure somebody will find a way.
POSIX quite clearly states that empty arguments are still arguments. Any
implementation doing otherwise is decidedly broken, even if it errs on
the side of prudence.
--
Andreas Ericsson andreas.ericsson at op5.se
OP5 AB www.op5.se
Lead Developer
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.
::: Messages without supporting info will risk being sent to /dev/null
More information about the Users
mailing list