[Nagiosplug-devel] check_icmp min and max
rader at hep.wisc.edu
rader at hep.wisc.edu
Tue Oct 28 15:46:43 CET 2008
Attached please find a patch that causes check_icmp to report
min and max round trip time perfdata.
It'd be nice if it got folded in.
I'm not sure if it'll apply cleanly to the latest in CVS.
(See my previous msg.)
steve
--
-------------- next part --------------
--- check_icmp.c.orig 2007-09-15 06:55:12.000000000 -0500
+++ check_icmp.c 2008-10-28 06:09:05.000000000 -0500
@@ -118,6 +118,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;
@@ -764,13 +766,13 @@
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|"
@@ -882,6 +884,8 @@
u_int i = 0;
unsigned char pl;
double rta;
+ double rtmax;
+ double rtmin;
struct rta_host *host;
char *status_string[] =
{"OK", "WARNING", "CRITICAL", "UNKNOWN", "DEPENDENT"};
@@ -975,9 +979,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);
@@ -1056,6 +1061,8 @@
host->saddr_in.sin_family = AF_INET;
host->saddr_in.sin_addr.s_addr = in->s_addr;
+ host->rtmin = 0xffffffff;
+
if(!list) list = cursor = host;
else cursor->next = host;
More information about the Devel
mailing list