int get_value(DB_ITEM *item, AGENT_RESULT *result) { int res = FAIL; zabbix_log(LOG_LEVEL_DEBUG, "In get_value(key:%s)", item->key); switch (item->type) { case ITEM_TYPE_ZABBIX: alarm(CONFIG_TIMEOUT); res = get_value_agent(item, result); alarm(0); if (SUCCEED != res && GET_MSG_RESULT(result)) zabbix_log(LOG_LEVEL_WARNING, "Item [%s] error: %s", zbx_host_key_string_by_item(item), result->msg); break; case ITEM_TYPE_SNMPv1: case ITEM_TYPE_SNMPv2c: case ITEM_TYPE_SNMPv3: #ifdef HAVE_SNMP alarm(CONFIG_TIMEOUT); res = get_value_snmp(item, result); alarm(0); #else SET_MSG_RESULT(result, strdup("Support of SNMP parameters was not compiled in")); res = NOTSUPPORTED; #endif if (SUCCEED != res && GET_MSG_RESULT(result)) zabbix_log(LOG_LEVEL_WARNING, "Item [%s] error: %s", zbx_host_key_string_by_item(item), result->msg); break; case ITEM_TYPE_IPMI: #ifdef HAVE_OPENIPMI res = get_value_ipmi(item, result); #else SET_MSG_RESULT(result, strdup("Support of IPMI parameters was not compiled in")); res = NOTSUPPORTED; #endif break; case ITEM_TYPE_SIMPLE: alarm(CONFIG_TIMEOUT); res = get_value_simple(item, result); alarm(0); break; case ITEM_TYPE_INTERNAL: alarm(CONFIG_TIMEOUT); res = get_value_internal(item, result); alarm(0); break; case ITEM_TYPE_DB_MONITOR: alarm(CONFIG_TIMEOUT); res = get_value_db(item, result); alarm(0); if (SUCCEED != res && GET_MSG_RESULT(result)) zabbix_log(LOG_LEVEL_WARNING, "Item [%s] error: %s", zbx_host_key_string_by_item(item), result->msg); break; case ITEM_TYPE_AGGREGATE: alarm(CONFIG_TIMEOUT); res = get_value_aggregate(item, result); alarm(0); break; case ITEM_TYPE_EXTERNAL: alarm(CONFIG_TIMEOUT); res = get_value_external(item, result); alarm(0); if (SUCCEED != res && GET_MSG_RESULT(result)) zabbix_log(LOG_LEVEL_WARNING, "Item [%s] error: %s", zbx_host_key_string_by_item(item), result->msg); break; default: zabbix_log(LOG_LEVEL_WARNING, "Not supported item type:%d", item->type); zabbix_syslog("Not supported item type:%d", item->type); res = NOTSUPPORTED; } zabbix_log(LOG_LEVEL_DEBUG, "End get_value()"); return res; }
static int get_value(DC_ITEM *item, AGENT_RESULT *result) { const char *__function_name = "get_value"; int res = FAIL; zabbix_log(LOG_LEVEL_DEBUG, "In %s() key:'%s'", __function_name, item->key_orig); switch (item->type) { case ITEM_TYPE_ZABBIX: alarm(CONFIG_TIMEOUT); res = get_value_agent(item, result); alarm(0); break; case ITEM_TYPE_SNMPv1: case ITEM_TYPE_SNMPv2c: case ITEM_TYPE_SNMPv3: #ifdef HAVE_SNMP alarm(CONFIG_TIMEOUT); res = get_value_snmp(item, result); alarm(0); #else SET_MSG_RESULT(result, zbx_strdup(NULL, "Support for SNMP checks was not compiled in")); res = NOTSUPPORTED; #endif break; case ITEM_TYPE_IPMI: #ifdef HAVE_OPENIPMI res = get_value_ipmi(item, result); #else SET_MSG_RESULT(result, zbx_strdup(NULL, "Support for IPMI checks was not compiled in")); res = NOTSUPPORTED; #endif break; case ITEM_TYPE_SIMPLE: /* simple checks use their own timeouts */ res = get_value_simple(item, result); break; case ITEM_TYPE_INTERNAL: res = get_value_internal(item, result); break; case ITEM_TYPE_DB_MONITOR: alarm(CONFIG_TIMEOUT); res = get_value_db(item, result); alarm(0); break; case ITEM_TYPE_AGGREGATE: res = get_value_aggregate(item, result); break; case ITEM_TYPE_EXTERNAL: /* external checks use their own timeouts */ res = get_value_external(item, result); break; case ITEM_TYPE_SSH: #ifdef HAVE_SSH2 alarm(CONFIG_TIMEOUT); res = get_value_ssh(item, result); alarm(0); #else SET_MSG_RESULT(result, zbx_strdup(NULL, "Support for SSH checks was not compiled in")); res = NOTSUPPORTED; #endif /* HAVE_SSH2 */ break; case ITEM_TYPE_TELNET: alarm(CONFIG_TIMEOUT); res = get_value_telnet(item, result); alarm(0); break; case ITEM_TYPE_CALCULATED: res = get_value_calculated(item, result); break; default: SET_MSG_RESULT(result, zbx_dsprintf(NULL, "Not supported item type:%d", item->type)); res = NOTSUPPORTED; } if (SUCCEED != res) { if (!ISSET_MSG(result)) SET_MSG_RESULT(result, zbx_strdup(NULL, "ZBX_NOTSUPPORTED")); zabbix_log(LOG_LEVEL_DEBUG, "Item [%s:%s] error: %s", item->host.host, item->key_orig, result->msg); zabbix_syslog("Item [%s:%s] error: %s", item->host.host, item->key_orig, result->msg); } /* remove formatting characters from the end of the result */ /* so it could be checked by "is_uint64" and "is_double" functions */ /* when we try to get "int" or "float" values from "string" result */ if (ISSET_STR(result)) zbx_rtrim(result->str, " \r\n"); if (ISSET_TEXT(result)) zbx_rtrim(result->text, " \r\n"); zabbix_log(LOG_LEVEL_DEBUG, "End of %s():%s", __function_name, zbx_result_string(res)); return res; }