[ZBX-14907] Setting 2-digit value for parameter "packet" s with icmpping / icmppingsec / icmppingloss will result in incorrect results Created: 2018 Sep 26  Updated: 2018 Sep 26  Resolved: 2018 Sep 26

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Proxy (P), Server (S)
Affects Version/s: None
Fix Version/s: None

Type: Incident report Priority: Trivial
Reporter: Kazuo Ito Assignee: Unassigned
Resolution: Incomplete Votes: 0
Labels: icmpping
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Zabbix4.0



 Description   

If 11 is specified for packet with icmpping, "- C 11" is executed by fping.

]# fping -C 11 127.0.0.1
127.0.0.1 : [0], 96 bytes, 0.04 ms (0.04 avg, 0% loss)
127.0.0.1 : [1], 96 bytes, 0.19 ms (0.11 avg, 0% loss)
127.0.0.1 : [2], 96 bytes, 0.04 ms (0.09 avg, 0% loss)
127.0.0.1 : [3], 96 bytes, 0.12 ms (0.09 avg, 0% loss)
127.0.0.1 : [4], 96 bytes, 0.03 ms (0.08 avg, 0% loss)
127.0.0.1 : [5], 96 bytes, 0.04 ms (0.07 avg, 0% loss)
127.0.0.1 : [6], 96 bytes, 0.04 ms (0.07 avg, 0% loss)
127.0.0.1 : [7], 96 bytes, 0.04 ms (0.06 avg, 0% loss)
127.0.0.1 : [8], 96 bytes, 0.12 ms (0.07 avg, 0% loss)
127.0.0.1 : [9], 96 bytes, 0.04 ms (0.07 avg, 0% loss)
127.0.0.1 : [10], 96 bytes, 0.11 ms (0.07 avg, 0% loss)

"status" is allocated 11byte of count value.

		for (i = 0; i < hosts_count; i++)
		{
			hosts[i].status = (char *)zbx_malloc(NULL, count);
			memset(hosts[i].status, 0, count);
		}

Parses the message returned from fping and acquires each value.
However, the program sees only one character after "[".

			if ('[' == *c)
			{
				/* Fping appends response source address in format '[<- 10.3.0.10]' */
				/* if it does not match the target address. Ignore such responses.  */
				if (NULL != strstr(c + 1, "[<-"))
					continue;

				/* get the index of individual ping response */
				index = atoi(c + 1);     <--- here!

				if (0 > index || index >= count)
					continue;

				host->status[index] = 1;

				continue;
			}

The "status" of "[10]" is stored in "status[1]".

The response time loops for count number, but the response time of "[10]" is ignored because "1" is not set in status.

			/* process status line for a host */
			index = 0;
			do
			{
				if (1 == host->status[index])
				{
					sec = atof(c) / 1000; /* convert ms to seconds */

					if (0 == host->rcv || host->min > sec)
						host->min = sec;
					if (0 == host->rcv || host->max < sec)
						host->max = sec;
					host->sum += sec;
					host->rcv++;
				}
			}
			while (++index < count && NULL != (c = strchr(c + 1, ' ')));


 Comments   
Comment by Vladislavs Sokurenko [ 2018 Sep 26 ]

Sorry, but I could not confirm the issue, here is the debug that I have added

Index: src/libs/zbxicmpping/icmpping.c
===================================================================
--- src/libs/zbxicmpping/icmpping.c	(revision 85166)
+++ src/libs/zbxicmpping/icmpping.c	(working copy)
@@ -315,7 +315,7 @@
 
 				/* get the index of individual ping response */
 				index = atoi(c + 1);
-
+				zabbix_log(LOG_LEVEL_INFORMATION, "c + 1 '%s' index %d", c + 1, index);
 				if (0 > index || index >= count)
 					continue

This resulted in :

 10738:20180926:094546.255 c + 1 '0], 84 bytes, 0.09 ms (0.09 avg, 0% loss)' index 0
 10738:20180926:094547.256 c + 1 '1], 84 bytes, 0.07 ms (0.08 avg, 0% loss)' index 1
 10738:20180926:094548.257 c + 1 '2], 84 bytes, 0.03 ms (0.06 avg, 0% loss)' index 2
 10738:20180926:094549.258 c + 1 '3], 84 bytes, 0.03 ms (0.05 avg, 0% loss)' index 3
 10738:20180926:094550.259 c + 1 '4], 84 bytes, 0.07 ms (0.05 avg, 0% loss)' index 4
 10738:20180926:094551.260 c + 1 '5], 84 bytes, 0.04 ms (0.05 avg, 0% loss)' index 5
 10738:20180926:094552.261 c + 1 '6], 84 bytes, 0.07 ms (0.05 avg, 0% loss)' index 6
 10738:20180926:094553.262 c + 1 '7], 84 bytes, 0.07 ms (0.05 avg, 0% loss)' index 7
 10738:20180926:094554.263 c + 1 '8], 84 bytes, 0.05 ms (0.05 avg, 0% loss)' index 8
 10738:20180926:094555.265 c + 1 '9], 84 bytes, 0.07 ms (0.05 avg, 0% loss)' index 9
 10738:20180926:094556.266 c + 1 '10], 84 bytes, 0.07 ms (0.06 avg, 0% loss)' index 10

Also there have been no changes to this code recently.

Comment by Kazuo Ito [ 2018 Sep 26 ]

Thank you for confirming the problem.

I added the same debugging sentence and confirmed it.
It works without problems as you have confirmed.

I checked to convert character string '10], 84 bytes, 0.06 ms (0.06 avg, 0% loss)' using atoi.

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]){
  int i;
  int n;
	
  for(i=1;i<argc;i++){
    n=atoi(argv[i]);
    printf("%d\n",n);
  }
  return 0;
}

It was converted to 10.

Because I was wrong, I would like to close this ticket.
I'm sorry.

Comment by Vladislavs Sokurenko [ 2018 Sep 26 ]

Thanks for looking into this, closing issue as there is no indication of a bug.

Generated at Fri Apr 26 12:07:59 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.