[Nagiosplug-devel] Nagios::Plugin thresholds
Gavin Carr
gavin at openfusion.com.au
Fri Sep 8 01:19:44 CEST 2006
On Thu, Sep 07, 2006 at 10:00:15AM -0800, Vonnahme, Nathan wrote:
> erm, I guess I'm kind of re-blending this with the general API
> discussion:
>
> Gavin wrote, though Outlook is too stupid to quote correctly:
>
> > How about something like this:
> >
> > $plugin->check_threshold(
> > check => $value, message => "page size at http://... was
> > ${value}kB",
> > warning => $warning, critical => $critical,
> > );
> >
> > which creates your N::P::Threshold object behind the scenes, sets the
> > thresholds using $warning and $critical, calls
> > N::P::Threshold->get_status,
> > and exits iff the result is a WARNING or a CRITICAL.
> >
> > You might also have:
> >
> > $plugin->check_threshold_exit( <same_args> );
> >
> > which always exits i.e. it's a convenience for:
> >
> > $self->check_threshold( %args );
> > $self->nagios_exit( OK, %args{message} );
>
>
> Wouldn't check_threshold return a valid nagios status code (OK, WARNING,
> CRITICAL) ?
<snip getopts>
> # then either
>
> my $return_status = $plugin->check_threshold(
> check => $value,
> warning => $plugin->opt('warning'), # it would have
> to call Nagios::Plugin::Getopt::getopts()
> # the first time
> we ask for an opt()
> critical => $plugin->opt('critical'),
> );
> $plugin->nagios_exit($return_status, $message);
>
> # or a shortcut like
>
> $plugin->check_threshold_exit(
> check => $value,
> message => $message,
> warning => $plugin->opt('warning'),
> critical => $plugin->opt('critical'),
> );
>
> and I would vote to *not* have that shortcut since it doesn't really
> save or clarify... you might just as well say:
>
> $plugin->nagios_exit(
> $plugin->check_threshold(
> check => $value,
> warning => $plugin->opt('warning'),
> critical => $plugin->opt('critical'),
> ),
> $message
> );
Yes, maybe you're right - there's not much in it. Maybe we leave the
shortcuts for now then? If we find down the track they would make
things easier (esp. for newbies) then they're easy enough to layer on
top.
More on check_threshold, I think we should make 'warning' and 'critical'
default to $plugin->opt('warning') and $plugin->opt('critical') if those
are defined, as that's likely to be far and away the common use case.
That would mean your example above just becomes:
my $return_status = $plugin->check_threshold( check => $value );
$plugin->nagios_exit( $return_status, $message );
Maybe we should allow:
my $return_status = $plugin->check_threshold( $value );
for that case as well?
So does this mean you're putting your hand up to implement this Nathan? ;-)
> also, I would still like to have a die() method so I'd be able to say
> something like:
>
> my $value = get_my_plugin_specific_stuff_here()
> or $plugin->die("couldn't check stuff because of foo!
> $!"); # returns UNKNOWN plus message
Okay, I guess that's a reasonable convenience method.
> On a side note, Gavin, is there any problem with standardizing on one
> spelling of license/licence in Getopt.pm ?
Er, well I speak the Queen's English, in which licence is the noun, and
license is the verb. I like helping American's understand that there's is
not the only brand on the planet, but I'm not _too_ much of a linguistic
Nazi. ;-)
So no, if you want to Americanise it I don't really care.
Cheers,
Gavin
More information about the Devel
mailing list