diff options
| author | sasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-02-05 09:34:26 +0000 |
|---|---|---|
| committer | sasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-02-05 09:34:26 +0000 |
| commit | 77bdb06094a060ab2def03ce9973c5331e27e9da (patch) | |
| tree | ced7d1d8ca4007e39fc58434b9baa7e1c507b2e7 /src | |
| parent | c7baec87cd3825785d33f66bad65493b4ff18e7d (diff) | |
- [ZBX-182] ICMP using host names
[svn merge svn://svn.zabbix.com/branches/1.4 -r5315:5319]
git-svn-id: svn://svn.zabbix.com/trunk@5320 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src')
| -rw-r--r-- | src/zabbix_server/pinger/pinger.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/zabbix_server/pinger/pinger.c b/src/zabbix_server/pinger/pinger.c index ccf24e41..b4d8bb94 100644 --- a/src/zabbix_server/pinger/pinger.c +++ b/src/zabbix_server/pinger/pinger.c @@ -33,10 +33,9 @@ int pinger_num; #define ZBX_FPING_HOST struct zbx_fipng_host ZBX_FPING_HOST { - char *host; char ip[HOST_IP_LEN_MAX]; char dns[HOST_DNS_LEN_MAX]; - int alive; + int alive, useip; double mseconds; }; @@ -66,16 +65,16 @@ static int process_value(char *key, ZBX_FPING_HOST *host, AGENT_RESULT *value) zabbix_log(LOG_LEVEL_DEBUG, "In process_value(%s@%s)", key, - host->host); + host->useip ? host->ip : host->dns); result = DBselect("select %s where h.status=%d and h.hostid=i.hostid" " and h.useip=%d and h.%s='%s' and i.key_='%s' and i.status=%d" " and i.type=%d and" ZBX_COND_NODEID, ZBX_SQL_ITEM_SELECT, HOST_STATUS_MONITORED, - host->host == host->ip ? 1 : 0, - host->host == host->ip ? "ip" : "dns", - host->host, + host->useip, + host->useip ? "ip" : "dns", + host->useip ? host->ip : host->dns, key, ITEM_STATUS_ACTIVE, ITEM_TYPE_SIMPLE, @@ -134,14 +133,14 @@ static int get_pinger_hosts(ZBX_FPING_HOST **hosts, int *hosts_allocated, int *h while (NULL != (row = DBfetch(result))) { if (*hosts_count == *hosts_allocated) { *hosts_allocated *= 2; - *hosts = zbx_realloc(*hosts, *hosts_allocated); + *hosts = zbx_realloc(*hosts, *hosts_allocated * sizeof(ZBX_FPING_HOST)); } host = &(*hosts)[*hosts_count]; memset(host, '\0', sizeof(ZBX_FPING_HOST)); strscpy(host->ip, row[0]); - host->host = host->ip; + host->useip = 1; (*hosts_count)++; @@ -165,14 +164,14 @@ static int get_pinger_hosts(ZBX_FPING_HOST **hosts, int *hosts_allocated, int *h while (NULL != (row = DBfetch(result))) { if (*hosts_count == *hosts_allocated) { *hosts_allocated *= 2; - *hosts = zbx_realloc(*hosts, *hosts_allocated); + *hosts = zbx_realloc(*hosts, *hosts_allocated * sizeof(ZBX_FPING_HOST)); } host = &(*hosts)[*hosts_count]; memset(host, '\0', sizeof(ZBX_FPING_HOST)); strscpy(host->dns, row[0]); - host->host = host->dns; + host->useip = 0; (*hosts_count)++; @@ -229,7 +228,7 @@ static int do_ping(ZBX_FPING_HOST *hosts, int hosts_count) } for (i = 0; i < hosts_count; i++) - fprintf(f, "%s\n", hosts[i].host); + fprintf(f, "%s\n", hosts[i].useip ? hosts[i].ip : hosts[i].dns); fclose(f); @@ -265,7 +264,7 @@ static int do_ping(ZBX_FPING_HOST *hosts, int hosts_count) if (c != NULL) { *c = '\0'; for (i = 0; i < hosts_count; i++) - if (0 == strcmp(tmp, hosts[i].host)) { + if (0 == strcmp(tmp, hosts[i].useip ? hosts[i].ip : hosts[i].dns)) { host = &hosts[i]; break; } @@ -289,7 +288,7 @@ static int do_ping(ZBX_FPING_HOST *hosts, int hosts_count) for (i = 0; i < hosts_count; i++) { zabbix_log(LOG_LEVEL_DEBUG, "Host [%s] alive [%d]", - hosts[i].host, + hosts[i].useip ? hosts[i].ip : hosts[i].dns, hosts[i].alive); init_result(&value); |
