[Nagiosplug-devel] Nagios::Plugin api

Gavin Carr gavin at openfusion.com.au
Sat Sep 2 03:07:58 CEST 2006


On Fri, Sep 01, 2006 at 06:17:00PM -0400, John P. Rouillard wrote:
> >Overloading die is nice, but it's reasonably unexpected from a user
> >point of view. I wonder if we should make Nagios::Plugin work something
> >like File::Spec does: by default, nothing is exported into the user's
> >environment, and everything is called via class or object methods e.g.
> >
> >  Nagios::Plugin->die( 'bad result' );
> >  $np->exit( 'everything ok' );
> >
> >Then you have an alternative functional interface if you want to use
> >exported/exportable functions instead (including overriding die, for
> >instance), like Nagios::Plugin::Functions (cf. File::Spec::Functions):
> >
> >  use Nagios::Plugin::Functions;
> >
> >  die( $failure, CRITICAL );
> 
> 
> Why use die at all? It is some attempt to make current programs using die
> return something useful?
> 
> Why not use nagios_exit("msg", $UNKNOWN) or some such. Overloading is
> nice if you understand it, but I see a lot of people making plugins
> that have only a bare grasp of programming. I think overloading die is
> just going to bring problems. A user does a google for die to see
> how to use it. Does s/he get info about the overloaded function?
> 
> On the other hand if they google for nagios_exit or some such they
> have a much better chance of finding useful info and examples.

It's a good point. In addition, we were talking about using both 'die'
and 'exit', and overloading 'exit' is non-trivial. I actually used
nagios_exit() in my earlier Nagios::Plugin variant, so +1 from me.

Cheers,
Gavin





More information about the Devel mailing list