ICMPPING failed

来源:互联网 发布:开淘宝要多少钱一个月 编辑:程序博客网 时间:2024/06/15 06:47

Zabbix uses external utility fping for processing of ICMP pings.

icmpping属于simple check,而不是agent。

如果从server端执行zabbix_get来获取icmpping的值,会返回ZBX_NOTSUPPORTED。

据说,icmpping无法通过zabbix_get命令获取结果,只能由zabbix服务调用。为什么???

zabbix_get的源代码中是使用下面的函数来获取数据的

ret = get_value(source_ip, host, port, key, &value);  

而get_value()函数的源码如下:

<pre name="code" class="cpp">/****************************************************************************** *                                                                            * * Function: get_value                                                        * *                                                                            * * Purpose: connect to Zabbix agent and receive value for given key           * *                                                                            * * Parameters: host   - server name or IP address                             * *             port   - port number                                           * *             key    - item's key                                            * *                                                                            * * Return value: SUCCEED - ok, FAIL - otherwise                               * *             value  - retrieved value                                       * *                                                                            * * Author: Eugene Grigorjev                                                   * *                                                                            * * Comments:                                                                  * *                                                                            * ******************************************************************************/static intget_value(const char *source_ip, const char *host, unsigned short port, const char *key, char **value){zbx_sock_ts;intret;char*buf, request[1024];assert(value);*value = NULL;if (SUCCEED == (ret = zbx_tcp_connect(&s, source_ip, host, port, GET_SENDER_TIMEOUT)))  //建立tcp连接{zbx_snprintf(request, sizeof(request), "%s\n", key);if (SUCCEED == (ret = zbx_tcp_send(&s, request))) //通过tcp连接发送请求{if (SUCCEED == (ret = SUCCEED_OR_FAIL(zbx_tcp_recv_ext(&s, &buf, ZBX_TCP_READ_UNTIL_CLOSE, 0)))) //获取返回结果{zbx_rtrim(buf, "\r\n");*value = strdup(buf);}}zbx_tcp_close(&s);}if (FAIL == ret)zbx_error("Get value error: %s", zbx_tcp_strerror());return ret;}
而监听进程是通过process函数来处理请求的,process函数位于sysinfo.c文件中:
<pre name="code" class="cpp">intprocess(const char *in_command, unsigned flags, AGENT_RESULT *result){intret = NOTSUPPORTED;ZBX_METRIC*command = NULL;AGENT_REQUESTrequest;init_result(result);init_request(&request);if (SUCCEED != parse_item_key(zbx_alias_get(in_command), &request))goto notsupported;/* system.run is not allowed by default except for getting hostname for daemons */if (1 != CONFIG_ENABLE_REMOTE_COMMANDS && 0 == (flags & PROCESS_LOCAL_COMMAND) &&0 == strcmp(request.key, "system.run")){goto notsupported;}for (command = commands; NULL != command->key; command++){if (0 == strcmp(command->key, request.key))break;}/* item key not found */if (NULL == command->key)goto notsupported;/* expected item from a module */if (0 != (flags & PROCESS_MODULE_COMMAND) && 0 == (command->flags & CF_MODULE))goto notsupported;/* command does not accept parameters but was called with parameters */if (0 == (command->flags & CF_HAVEPARAMS) && 0 != request.nparam)goto notsupported;if (0 != (command->flags & CF_USERPARAMETER)){if (0 != (command->flags & CF_HAVEPARAMS)){char*parameters = NULL, error[MAX_STRING_LEN];if (FAIL == replace_param(command->test_param, &request, ¶meters, error, sizeof(error))){zabbix_log(LOG_LEVEL_WARNING, "item [%s] error: %s", in_command, error);goto notsupported;}free_request_params(&request);add_request_param(&request, parameters);}else{free_request_params(&request);add_request_param(&request, zbx_strdup(NULL, command->test_param));}}if (SYSINFO_RET_OK != command->function(&request, result)){/* "return NOTSUPPORTED;" would be more appropriate here for preserving original error *//* message in "result" but would break things relying on ZBX_NOTSUPPORTED message. */goto notsupported;}ret = SUCCEED;notsupported:free_request(&request);if (NOTSUPPORTED == ret){UNSET_MSG_RESULT(result);SET_MSG_RESULT(result, zbx_strdup(NULL, ZBX_NOTSUPPORTED));}return ret;}


                                             
0 0
原创粉丝点击