[Nagiosplug-devel] performance data patch for check_ping.c
Christian Schneemann
cschneemann at suse.de
Wed Apr 23 19:10:00 CEST 2008
On Wednesday April 23 2008 05:05:08 pm Thomas Guyot-Sionnest wrote:
> Christian Schneemann wrote:
> | Hi,
>
> Hi Christian,
>
> | it is not realy a patch, it is just one added line, but maybe it is
>
> helpfull.
>
> | I've just added a line to print the perfdata, I've tested it with Nagios
> | 3.0.1.
> |
> | --- plugins/check_ping.c
> | +++ plugins/check_ping.c
> | @@ -165,6 +165,7 @@
> | state_text (this_result), warn_text, pl, rta);
> | if (display_html == TRUE)
> | printf ("</A>");
> | + printf("|rta=%2.2f;%f;%f;; pl=%d%%;%d%%;%d%%;;", rta,
>
> wrta,
>
> | crta, pl, wpl, cpl);
> | printf ("\n");
> |
> | if (verbose >= 2)
>
> Thanks for summiting a patch. Unfortunately I can't accept it as it's
> not using the perfdata functions provided y nagios plugins. This sure
> could be useful and I'll put it in my todo list. Alternatively you can
> repost your patch using the proper function (look at other plugins for
> examples).
>
> It should be noted that check_icmp already provides performance data and
> should be preferred over check_ping wherever possible (it requires root
> privileges so it has to be owned by root and needs the suid permission
> bit set - might also have issues regarding ping intervals and sequence
> numbers). check_icmp has a native ICMP implementation and therefore does
> not rely on the ping command (and does not fork anything either).
>
> Thanks,
Ok, here a new try using fperdata():
--- plugins/check_ping.c
+++ plugins/check_ping.c
@@ -165,7 +165,7 @@
state_text
(this_result), warn_text, pl, rta);
if (display_html == TRUE)
printf ("</A>");
- printf ("\n");
+ printf("|%s\n", fperfdata ("rta", (double) rta, "ms", FALSE,
0, FALSE, 0, FALSE, 0, FALSE, 0));
if (verbose >= 2)
printf ("%f:%d%% %f:%d%%\n", wrta, wpl, crta, cpl);
I have a question to the perfdata() and fperdata() functions.
char *fperfdata (const char *label,
double val,
const char *uom,
int warnp,
double warn,
int critp,
double crit,
int minp,
double minv,
int maxp,
double maxv)
Both have (almost) the same parameters, fperfdata for float values, perfdata
for integers, but how are the switches (warnp, critp, minp, maxp) used? Must
they be set if the next parameter should be activated? So has warnp be TRUE
if the check gives back a WARNING state?
How could they be used adequate in this case?
I had a look at some checks using perfdata() or fperfdata, and I think I now
have a check_ping, that can be used for performancedata. But I don't know
what has to be set if the performance should be monitored more exactly.
It is hard to use a function just from looking at how it is used from others,
a documentation is very helpful (yes, I have the best documentation, the
sourcecode, but a written text can be easier to read ;)
Greetings
--
Christian Schneemann
-------------------------------------
SUSE LINUX Products GmbH,
Maxfeldstr. 5, D - 90409 Nürnberg
Phone: +49 (0)911 - 740 53 0
e-mail: cschneemann at suse.de
-------------------------------------
SUSE LINUX Products GmbH, GF: Markus Rex
HRB 16746 (AG Nürnberg)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nagios-plugins-perfdata.patch
Type: text/x-diff
Size: 371 bytes
Desc: not available
URL: <http://nagios-plugins.org/archive/devel/attachments/20080423/53aed8e1/attachment.patch>
More information about the Devel
mailing list