3128:20150429:114455.871 history data from active proxy on “115.29.182.109” failed: proxy “jinrong” not found
[root@monitor src]# grep “history data from active proxy” * -r|more
zabbix_server/trapper/trapper.c: zabbix_log(LOG_LEVEL_WARNING, “history data from active proxy on ”%s” failed: %s”,
得出是trapper.c 致使。
/******************************************************************************
* *
* Function: recv_proxyhistory *
* *
* Purpose: processes the received values from active proxies *
* *
******************************************************************************/
static void recv_proxyhistory(zbx_sock_t *sock, struct zbx_json_parse *jp)
{
const char *__function_name = "recv_proxyhistory";
zbx_uint64_t proxy_hostid;
char host[HOST_HOST_LEN_MAX], *error = NULL;
int ret;
zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __function_name);
if (SUCCEED != (ret = get_active_proxy_id(jp, &proxy_hostid, host, &error)))
{
zabbix_log(LOG_LEVEL_WARNING, "history data from active proxy on "%s" failed: %s",
get_ip_by_socket(sock), error);
goto out;
}
update_proxy_lastaccess(proxy_hostid);
ret = process_hist_data(sock, jp, proxy_hostid, error, sizeof(error));
out:
zbx_send_response(sock, ret, error, CONFIG_TIMEOUT);
zbx_free(error);
zabbix_log(LOG_LEVEL_DEBUG, "End of %s()", __function_name);
}
也就是说 get_active_proxy_id(jp, &proxy_hostid, host, &error)) 这个函数履行不正确的话,会报上面的错。
问题又转化为 get_active_proxy_id的履行了。
继续搜索 get_active_proxy_id 这个函数的源码文件,
[root@monitor src]# grep get_active_proxy_id * -r
Binary file libs/zbxdbhigh/libzbxdbhigh.a matches
Binary file libs/zbxdbhigh/libzbxdbhigh_a-proxy.o matches
libs/zbxdbhigh/proxy.c: * Function: get_active_proxy_id *
libs/zbxdbhigh/proxy.c:int get_active_proxy_id(struct zbx_json_parse *jp, zbx_uint64_t *hostid, char *host, char **error)
Binary file zabbix_server/trapper/proxyhosts.o matches
zabbix_server/trapper/proxydiscovery.c: if (SUCCEED != (ret = get_active_proxy_id(jp, &proxy_hostid, host, &error)))
zabbix_server/trapper/trapper.c: if (SUCCEED != (ret = get_active_proxy_id(jp, &proxy_hostid, host, &error)))
zabbix_server/trapper/trapper.c: if (SUCCEED != (ret = get_active_proxy_id(jp, &proxy_hostid, host, &error)))
Binary file zabbix_server/trapper/trapper.o matches
Binary file zabbix_server/trapper/proxydiscovery.o matches
Binary file zabbix_server/trapper/proxyconfig.o matches
zabbix_server/trapper/proxyautoreg.c: if (SUCCEED != (ret = get_active_proxy_id(jp, &proxy_hostid, host, &error)))
zabbix_server/trapper/proxyconfig.c: if (SUCCEED != get_active_proxy_id(jp, &proxy_hostid, host, &error))
Binary file zabbix_server/trapper/proxyautoreg.o matches
Binary file zabbix_server/trapper/libzbxtrapper.a matches
zabbix_server/trapper/proxyhosts.c: if (SUCCEED != (ret = get_active_proxy_id(jp, &proxy_hostid, host, &error)))
Binary file zabbix_server/zabbix_server matches
可以看到是在libs/zbxdbhigh/proxy.c 文件中定义
/******************************************************************************
* *
* Function: get_active_proxy_id *
* *
* Purpose: extract a proxy name from JSON and find the proxy ID in database. *
* The proxy must be configured in active mode. *
* *
* Parameters: jp - [IN] JSON with the proxy name *
* hostid - [OUT] proxy host ID found in database *
* host - [IN] buffer with minimum size *
* 'HOST_HOST_LEN_MAX' *
* error - [OUT] error message *
* *
* Return value: SUCCEED - proxy ID was found in database *
* FAIL - an error occurred (e.g. an unknown proxy or the *
* proxy is configured in passive mode *
* *
* Author: Alexander Vladishev *
* *
******************************************************************************/
int get_active_proxy_id(struct zbx_json_parse *jp, zbx_uint64_t *hostid, char *host, char **error)
{
DB_RESULT result;
DB_ROW row;
char *host_esc;
int ret = FAIL, status;
if (SUCCEED == zbx_json_value_by_name(jp, ZBX_PROTO_TAG_HOST, host, HOST_HOST_LEN_MAX))
{
if (FAIL == zbx_check_hostname(host))
{
*error = zbx_dsprintf(*error, "invalid proxy name "%s"", host);
return ret;
}
host_esc = DBdyn_escape_string(host);
result = DBselect(
"select hostid,status"
" from hosts"
" where host='%s'"
" and status in (%d,%d)"
ZBX_SQL_NODE,
host_esc, HOST_STATUS_PROXY_ACTIVE, HOST_STATUS_PROXY_PASSIVE,
DBand_node_local("hostid"));
zbx_free(host_esc);
if (NULL != (row = DBfetch(result)) && FAIL == DBis_null(row[0]))
{
if (SUCCEED == is_uint31(row[1], &status))
{
if (HOST_STATUS_PROXY_ACTIVE == status)
{
ZBX_STR2UINT64(*hostid, row[0]);
ret = SUCCEED;
}
else
{
*error = zbx_dsprintf(*error, "proxy "%s" is configured in passive mode",
host);
}
}
else
THIS_SHOULD_NEVER_HAPPEN;
}
else
*error = zbx_dsprintf(*error, "proxy "%s" not found", host);
DBfree_result(result);
}
else
*error = zbx_strdup(*error, "missing name of proxy");
return ret;
}
分析这段源码,也就是说hosts表中查不到的时候是会报 proxy ”%s” not found 的。
MySQL [zabbix]> desc hosts;
+――――――