[Nagiosplug-devel] Nagios:Plugin feedback

Thomas Guyot-Sionnest Thomas at zango.com
Fri Jan 19 16:53:54 CET 2007


> -----Original Message-----
> From: nagiosplug-devel-bounces at lists.sourceforge.net 
> [mailto:nagiosplug-devel-bounces at lists.sourceforge.net] On 
> Behalf Of Andreas Ericsson
> Sent: January 19, 2007 8:56
> To: Nagios Plugin Development Mailing List
> Subject: Re: [Nagiosplug-devel] Nagios:Plugin feedback
> 
> Thomas Guyot-Sionnest wrote:
> > 
> > There's many useful functions in the C API for Nagios 
> plugins. I believe
> > it wouldn't be a bad idea to have the same kind of function directly
> > into Nagios::Plugin. By minimizing the use of external modules, you
> > simplify plugin deployment.
> > 
> > Nagios::Plugin could itself load external modules to do the 
> checks, but
> > those dependencies would be installed along with Nagios::Plugin.
> > 
> > What I'm starting to realize is that there's nothing to check the
> > validity of arguments. In C you have all those functions:
> > 
> > is_integer
> > is_intpos
> > is_intneg
> > is_intnonneg
> > is_intpercent
> > is_numeric
> > is_positive
> > is_negative
> > is_nonnegative
> > is_percentage
> > 
> 
> Please, pretty please, don't mention those. They are 
> extremely bad examples
> of C programming. ALL of them can, even from the callers perspective
> be replaced with shorter versions that are already C89 compliant.
> 
> Most of them also duplicate checks already implemented in the 
> libc functions
> and *NONE* of them return the computed value to the caller. 
> Each time you see
> one of those functions used, you will know for a fact that 
> several operations
> are carried out at least twice. It's usually worse than that, 
> because it's often
> done in subtly (and pointless) different ways that the 
> compiler can't optimize
> away.

Oh, Thanks. I'm not a very experienced Perl programmer, and even worse C
programmer, so that's good to know.

It would be nice then to know the replacements, and possibly start a project
to clean up those (And any other that need to go) so we can eventually
remove that from utils.c/h. Or is there any reason why we wouldn't want to
do that?

This could be for a future v2 release, among with newer style tresholds
args, etc... Meanwhile the devlopper guidelines could mention which
functions not to use, and the recommended replacements. I often refer to
other plugins to decide how I should do things and they apparently aren't
always good examples.

Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3076 bytes
Desc: not available
URL: <http://nagios-plugins.org/archive/devel/attachments/20070119/0b354412/attachment.bin>


More information about the Devel mailing list