[Nagiosplug-devel] check_icmp min and max
rader at hep.wisc.edu
rader at hep.wisc.edu
Tue Oct 28 19:55:39 CET 2008
> Please re-send with indentation matching that of the surrounding
> code. That is:
> * Don't put space after opening parentheses or before closing
> parentheses.
> * Put newlines after if() statements.
> * Put closing curlies on their own lines.
Sure. Sorry for not thinking about the formatting earlier.
I also checked to make sure all the new code indents with
hard tabs.
> > + host->rtmin = 0xffffffff;
> > +
>
> This should generate a warning, as it would generate bogus assembly
> without compiler interference. Assign it to a really huge double
> value instead. Feel free to use scientific notation, like so:
> #define RTMIN_MAGIC_CONSTANT 50e200
> host->rtmin = RTMIN_MAGIC_CONSTANT
>
> rest assured that that particular magic constant will always be
> larger than any rtmin you can possibly get, so it won't interfere
> with the actual setting of the value.
Sure. (I used MAXDOUBLE, da.) Shall I ask a
Physicist how far across the Universe that'd get us??
steve
--
-------------- next part --------------
--- check_icmp.c.orig 2008-08-07 21:08:08.000000000 -0500
+++ check_icmp.c 2008-10-28 13:31:48.000000000 -0500
@@ -106,6 +106,7 @@
# define ICMP_UNREACH_PRECEDENCE_CUTOFF 15
#endif
+#define RTMIN_MAGIC_CONSTANT 9.999999999999999e999
typedef unsigned short range_t; /* type for get_range() -- unimplemented */
@@ -120,6 +121,8 @@
unsigned char icmp_type, icmp_code; /* type and code from errors */
unsigned short flags; /* control/status flags */
double rta; /* measured RTA */
+ double rtmax; /* max rtt */
+ double rtmin; /* min rtt */
unsigned char pl; /* measured packet loss */
struct rta_host *next; /* linked list */
} rta_host;
@@ -782,13 +785,15 @@
host->time_waited += tdiff;
host->icmp_recv++;
icmp_recv++;
-
+ if (tdiff > host->rtmax)
+ host->rtmax = tdiff;
+ if (tdiff < host->rtmin)
+ host->rtmin = tdiff;
if(debug) {
- printf("%0.3f ms rtt from %s, outgoing ttl: %u, incoming ttl: %u\n",
+ printf("%0.3f ms rtt from %s, outgoing ttl: %u, incoming ttl: %u, max: %0.3f, min: %0.3f\n",
(float)tdiff / 1000, inet_ntoa(resp_addr.sin_addr),
- ttl, ip->ip_ttl);
+ ttl, ip->ip_ttl, (float)host->rtmax / 1000, (float)host->rtmin / 1000);
}
-
/* if we're in hostcheck mode, exit with limited printouts */
if(mode == MODE_HOSTCHECK) {
printf("OK - %s responds to ICMP. Packet %u, rta %0.3fms|"
@@ -900,6 +905,8 @@
u_int i = 0;
unsigned char pl;
double rta;
+ double rtmax;
+ double rtmin;
struct rta_host *host;
const char *status_string[] =
{"OK", "WARNING", "CRITICAL", "UNKNOWN", "DEPENDENT"};
@@ -993,9 +1000,10 @@
host = list;
while(host) {
if(debug) puts("");
- printf("%srta=%0.3fms;%0.3f;%0.3f;0; %spl=%u%%;%u;%u;; ",
+ printf("%srta=%0.3fms;rtmax=%0.3fms;rtmin=%0.3fms;%0.3f;%0.3f;0; %spl=%u%%;%u;%u;; ",
(targets > 1) ? host->name : "",
- host->rta / 1000, (float)warn.rta / 1000, (float)crit.rta / 1000,
+ host->rta / 1000, host->rtmax / 1000, host->rtmin / 1000,
+ (float)warn.rta / 1000, (float)crit.rta / 1000,
(targets > 1) ? host->name : "",
host->pl, warn.pl, crit.pl);
@@ -1074,6 +1082,8 @@
host->saddr_in.sin_family = AF_INET;
host->saddr_in.sin_addr.s_addr = in->s_addr;
+ host->rtmin = RTMIN_MAGIC_CONSTANT;
+
if(!list) list = cursor = host;
else cursor->next = host;
More information about the Devel
mailing list