[Nagiosplug-devel] RFC: supporting ranges in *perfdata()

Sebastian Harl tokkee at debian.org
Fri Apr 1 16:04:31 CEST 2011


Hi there,

currently, the *perfdata() formatting functions in plugins/utils.c do
not support anything but a single integer value for warning and critical
values. However, according to the plug-in development guidelines,
section 2.6 [1], the warn and crit fields are supposed to support the
range format (as specified in section 2.5).

Are there any plans and/or work going on to add support for ranges?

Else, I'd propose to introduce a new function called 'np_strfperfdata'
to be added to libnagiosplug using the following signature:

  char *np_strfperfdata(const char *label,
        long int val, const char *uom,
        thresholds *thres,
        int minp, long int minv,
        int maxp, long int maxv);

… and the same for floating point values (called 'np_strfperfdataf').

I would have preferred to avoid introducing two functions for that
purpose. However, I could only think of two ways to get there (and I
don't really like either of them):

 * Introduce a union like

   union np_value {
       long int integer;
       double   floating;
   }

   … and an enum np_value_type { TYPE_NONE, TYPE_INT, TYPE_FLOAT } to be
   used as argument types:

   char *np_strfperfdata(const char *label,
         enum np_value_type type, union np_value val, const char *uom,
         thresholds *thres,
         enum np_value_type min_type, union np_value min,
         enum np_value_type max_type, union np_value max);

 * Use variable argument lists and a format string describing the
   arguments:

   char *np_strfperfdata(const char *label, const char *fmt, ...)

   'fmt' would support the following conversion specifications to be
   applied to the variable arguments:

   - %Vi, %Vf: integer / floating value
   - %T: threshold
   - %mi, %mf: integer / floating min
   - %Mi, %Mf: integer / floating max

Both approaches would be rather ugly, though ;-)

Any comments, suggestions would be appreciated.

TIA,
Sebastian

[1] <http://nagiosplug.sourceforge.net/developer-guidelines.html#AEN201>

-- 
Sebastian "tokkee" Harl +++ GnuPG-ID: 0x8501C7FC +++ http://tokkee.org/

Those who would give up Essential Liberty to purchase a little Temporary
Safety, deserve neither Liberty nor Safety.         -- Benjamin Franklin

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <https://www.monitoring-plugins.org/archive/devel/attachments/20110401/b583abda/attachment.sig>


More information about the Devel mailing list