运维运维
分类: 系统运维
2014-11-02 01:18:17
int NET_TCP_LISTEN(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) { FILE *f = NULL; char tmp[MAX_STRING_LEN], pattern[64]; unsigned short port; zbx_uint64_t listen = 0; int ret = SYSINFO_RET_FAIL; if (num_param(param) > 1) return ret; if (0 != get_param(param, 1, tmp, sizeof(tmp))) return ret; if (SUCCEED != is_ushort(tmp, &port)) return ret; if (NULL != (f = fopen("/proc/net/tcp", "r"))) { zbx_snprintf(pattern, sizeof(pattern), "%04X 00000000:0000 0A", (unsigned int)port); while (NULL != fgets(tmp, sizeof(tmp), f)) { if (NULL != strstr(tmp, pattern)) { listen = 1; break; } } zbx_fclose(f); ret = SYSINFO_RET_OK;
} if (0 == listen && NULL != (f = fopen("/proc/net/tcp6", "r"))) { zbx_snprintf(pattern, sizeof(pattern), "%04X 00000000000000000000000000000000:0000 0A", (unsigned int)port); while (NULL != fgets(tmp, sizeof(tmp), f)) { if (NULL != strstr(tmp, pattern)) { listen = 1; break; } } zbx_fclose(f); ret = SYSINFO_RET_OK; } SET_UI64_RESULT(result, listen); return ret;经过查看可以得知,net.tcp.listen是从
/proc/net/tcp读取的数据,查看
/proc/net/tcp文件的行数,果然很大,ZABBIX AGENT执行KEY的最大时间为30S。在30S中没有完成,导致了该问题的发现。然后SERVER端会在120S内重新连接ZABBIX-AGEENT,在这120S中