[Nagiosplug-devel] Nagios::Plugin with multiple threshold limits?
Gavin Carr
gavin at openfusion.com.au
Tue Apr 3 02:11:23 CEST 2007
Hi Klaus,
I'm copying the Nagios Plug-Devel list as well, since we usually try to discuss
Nagios::Plugin stuff on-list there.
On Mon, Apr 02, 2007 at 06:28:00PM +0200, Pesendorfer, Klaus wrote:
> I've discovered your really nice Perl module Nagios::Plugin these days and began
> to test it for my needs.
Great! We're very interested in people starting to use it for real tasks now, so
we value your feedback. I take it you're using version 0.17, right?
> Now I'm at the point where the documentation doesn't tell me any more details,
> I would like to know.
>
> Is it possible to use more than one threshold definition in one call?
>
> So that I could for example check the 3 load average parameters with -w 5,6,7
> -c 10,11,12 [I know that a check_load plugin exists ... that's only an example ;-) ]
>
> Alternatively the Nagios Plugin Devel-Guidelines allow the syntax: -w 5 -w 6 -w 7
> -c 10 -c 11 -c 12 (I do prefer the first one more)
Right now we don't have builtin support for multiple thresholds, but it would be nice.
I'll add it to the TODO list. That said, you should be able to handle multiple
thresholds right now pretty easily - see below.
> The first method could not be parsed
as integers, I guess you mean? Yes, you've have to specify it as a string and then
split on the commas at the moment.
> and the second one's problem is, that the parsed parameters overwrite themselves.
This should work fine, but you'd need to specify the argument as an array e.g.
spec => 'warning|w=i@' # OR:
spec => 'warning|w=s@'
in which case $np->opts->warning would be an array reference, and you could do
something like this, given an @check array of values to check:
for my $i ( 0 .. $#check ) {
$code = $np->check_threshold(
check => $check[$i],
warning => $np->opts->warning->[$i],
critical => $np->opts->critical->[$i],
);
# Do something if $code != OK
}
> (Is it possible to store more than one threshold object in the plugin data structure
> or do I need to store them somewhere else?)
You shouldn't usually need to manipulate threshold objects directly - you should be
able to do what you want via check_threshold.
We do need to add a couple of things here though - a way of specifying that a given
argument is actually a threshold (at the moment by and large we just treat everything
as scalars); and support for sets of thresholds, rather than just one.
> p.s.: Do I really need all these perl requirements? (Class:Accessor, Params::Validate,
> Config::Tiny, Math::Calc::Units)
I think in some ways we're still discussing this. We're trying to find a balance
between requiring a minimal number of dependencies, and not reinventing the wheel when
there are already standardised solutions out there on CPAN.
> The dependency "Test::More" was only solvable by settinging the version to 0 instead
> of 0.62 (by using the default perl Modules of V.5.8.5). (did I do something wrong?)
That's probably set too high then. What version of Test::More do you have, and what's
your platform?
perl -MTest::More -le 'print $Test::More::VERSION'
Regards,
Gavin
More information about the Devel
mailing list