Source
zbx_snprintf(linebuf, linebuf_size, "%s %s 2>&1 <%s", config_icmpping->get_fping_location(), params, filename);
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
static const zbx_config_icmpping_t *config_icmpping;
/* old official fping (2.4b2_to_ipv6) did not support source IP address */
/* old patched versions (2.4b2_to_ipv6) provided either -I or -S options */
/* since fping 3.x it provides -I option for binding to an interface and -S option for source IP address */
static ZBX_THREAD_LOCAL unsigned char source_ip_checked;
static ZBX_THREAD_LOCAL const char *source_ip_option;
static ZBX_THREAD_LOCAL unsigned char source_ip6_checked;
static ZBX_THREAD_LOCAL const char *source_ip6_option;
static ZBX_THREAD_LOCAL int packet_interval;
static ZBX_THREAD_LOCAL int packet_interval6;
static ZBX_THREAD_LOCAL int fping_ipv6_supported;
static ZBX_THREAD_LOCAL time_t fping_check_reset_at; /* time of the last fping options expiration */
static ZBX_THREAD_LOCAL char tmpfile_uniq[255] = {'\0'};
typedef struct
{
zbx_fping_host_t *hosts;
int hosts_count;
int requests_count;
unsigned char allow_redirect;
int rdns;
char fping_existence;
}
zbx_fping_args;
typedef struct
{
FILE *input_pipe;
char *linebuf;
size_t linebuf_size;
}
zbx_fping_resp;
static void get_source_ip_option(const char *fping, const char **option, unsigned char *checked)
{
FILE *f;
char *p, tmp[MAX_STRING_LEN];
zbx_snprintf(tmp, sizeof(tmp), "%s -h 2>&1", fping);
zabbix_log(LOG_LEVEL_DEBUG, "executing %s", tmp);
if (NULL == (f = popen(tmp, "r")))
return;
while (NULL != zbx_fgets(tmp, sizeof(tmp), f))
{
for (p = tmp; isspace(*p); p++)
;
if ('-' == p[0] && 'I' == p[1] && (isspace(p[2]) || ',' == p[2]))
{
*option = "-I";
continue;
}