[Nagiosplug-devel] Nagios::Plugin suggestions

Ton Voon ton.voon at altinity.com
Thu Feb 8 16:30:47 CET 2007


Hi!

I've just started using Nagios::Plugin in earnest because I am going  
to do a public demo of this soon (hush, hush details, but I will let  
you all know soon :) ). I had a couple of suggestions.

Firstly, good job Gavin and Nathan! I can see the framework is coming  
along nicely and is amazing how little needs to be coded to get a lot  
of support for extraneous stuff.


ADD_ARG METHOD

For $np->add_arg(), one thing I've noticed myself repeating is the  
help output. The syntax output is effectively already defined in the  
spec. Plus, to get the output lined up correctly with the default  
args in --help, you need to add a linefeed and extra spaces. What about:

$np->add_arg(
   spec => "warning|w=s",
   type => "RANGE",
   help => "Warning if time is outside RANGE",
   );

The idea is that the spec line will print "-w, --warning=RANGE", with  
a new line and the appropriate number of spaces before printing $help.

This should also make it a bit easier to internationalisation as the  
help line is the only portion that needs translating.

I'm also thinking ahead to new threshold formats, so that if type is  
THRESHOLD, some other processing can happen (validation of threshold  
values?).

We can be backwards compatible so that the old behaviour happens if  
type is not specified (though mark this as deprecated behaviour).

Also, I'd like to add default => "5" to the add_arg, if you wish to  
set a default value.


HELP OUTPUT

Currently this is sent to stderr. This should be stdout with respects  
to the C plugins, though I can't find it documented in the dev  
guidelines. Agreed?


MAX_STATE

I've added a max_state function into N::P::Functions that mimics the  
C version, but not sure how to add into the N::P object. It seems  
that the object itself doesn't have the idea of a current state -  
would that be a good idea or not? If the object does know state, then  
$np->max_state( $new_state ) could do a $self->state( new_state 
( $self->state || "", $new_state) ) ?

Ton

http://www.altinity.com
T: +44 (0)870 787 9243
F: +44 (0)845 280 1725
Skype: tonvoon






More information about the Devel mailing list