[collectd] libping bugfix
tommie at gannert.se
Tue Jan 31 16:27:16 CET 2006
I've finally got around fixing a problem I had with the ping plugin.
This patch sets the icmp_seq value to something (and clearing everything else, just for the sake of it). I found that some of my ping hosts (namely my ISP:s gateway and DNS server) wouldn't reply if icmp_seq was 0.
It was okay for the first host, but since nothing sets icmp_seq in the original code, a zero happened to be on the stack during the next iterations in the ping plugin. As a result, the graphs showed NaN.
diff -Nru collectd-3.7.0-orig/src/libping/ping.c collectd-3.7.0/src/libping/ping.c
--- collectd-3.7.0-orig/src/libping/ping.c 2006-01-30 22:59:21.000000000 +0100
+++ collectd-3.7.0/src/libping/ping.c 2006-01-31 14:10:45.000000000 +0100
@@ -172,11 +172,13 @@
+ memset(buf, 0, sizeof(buf));
icp = (struct icmp *)buf;
icp->icmp_type = ICMP_ECHO;
icp->icmp_code = 0;
icp->icmp_cksum = 0;
icp->icmp_id = getpid() & 0xFFFF;
+ icp->icmp_seq = icp->icmp_id;
icp->icmp_cksum = in_checksum((u_short *)icp, len );
if(( ss = sendto( datum->sock, buf, sizeof( buf ), 0,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Collectd