int get_value_ipmi(DC_ITEM *item, AGENT_RESULT *value) { const char *__function_name = "get_value_ipmi"; zbx_ipmi_host_t *h; zbx_ipmi_sensor_t *s; zbx_ipmi_control_t *c = NULL; zabbix_log(LOG_LEVEL_DEBUG, "In %s() key:'%s:%s'", __function_name, item->host.host, item->key_orig); if (NULL == os_hnd) { SET_MSG_RESULT(value, strdup("IPMI handler is not initialised")); return NOTSUPPORTED; } h = init_ipmi_host(item->interface.addr, item->interface.port, item->host.ipmi_authtype, item->host.ipmi_privilege, item->host.ipmi_username, item->host.ipmi_password); if (0 == h->domain_up) { if (NULL != h->err) { SET_MSG_RESULT(value, strdup(h->err)); } return h->ret; } s = get_ipmi_sensor_by_id(h, item->ipmi_sensor); if (NULL == s) c = get_ipmi_control_by_name(h, item->ipmi_sensor); if (NULL == s && NULL == c) { SET_MSG_RESULT(value, zbx_dsprintf(NULL, "sensor or control %s@[%s]:%d does not exist", item->ipmi_sensor, h->ip, h->port)); return NOTSUPPORTED; } if (NULL != s) read_ipmi_sensor(h, s); else read_ipmi_control(h, c); if (h->ret != SUCCEED) { if (NULL != h->err) { SET_MSG_RESULT(value, strdup(h->err)); } return h->ret; } if (NULL != s) { if (IPMI_EVENT_READING_TYPE_THRESHOLD == s->reading_type) SET_DBL_RESULT(value, s->value.threshold); else SET_UI64_RESULT(value, s->value.discrete); } if (NULL != c) SET_DBL_RESULT(value, c->val[0]); zabbix_log(LOG_LEVEL_DEBUG, "End of %s():%s", __function_name, zbx_result_string(h->ret)); return h->ret; }
int get_value_ipmi(DB_ITEM *item, AGENT_RESULT *value) { zbx_ipmi_host_t *h; zbx_ipmi_sensor_t *s; zbx_ipmi_control_t *c = NULL; zabbix_log(LOG_LEVEL_DEBUG, "In get_value_ipmi(key:%s)", item->key); if (NULL == os_hnd) { zabbix_log(LOG_LEVEL_DEBUG, "%s", "IPMI handler is not initialised"); SET_MSG_RESULT(value, strdup("IPMI handler is not initialised")); return NOTSUPPORTED; } h = init_ipmi_host(item->ipmi_ip, item->ipmi_port, item->ipmi_authtype, item->ipmi_privilege, item->ipmi_username, item->ipmi_password); if (0 == h->domain_up) { if (NULL != h->err) { zabbix_log(LOG_LEVEL_DEBUG, "%s", h->err); SET_MSG_RESULT(value, strdup(h->err)); } return h->ret; } s = get_ipmi_sensor_by_name(h, item->ipmi_sensor); if (NULL == s) c = get_ipmi_control_by_name(h, item->ipmi_sensor); if (NULL == s && NULL == c) { zabbix_log(LOG_LEVEL_DEBUG, "Sensor or control %s@[%s]:%d does not exist", item->ipmi_sensor, h->ip, h->port); SET_MSG_RESULT(value, strdup("Sensor or control does not exist")); return NOTSUPPORTED; } if (NULL != s) read_ipmi_sensor(h, s); else read_ipmi_control(h, c); if (h->ret != SUCCEED) { if (NULL != h->err) { zabbix_log(LOG_LEVEL_DEBUG, "%s", h->err); SET_MSG_RESULT(value, strdup(h->err)); } return h->ret; } if (NULL != s) SET_DBL_RESULT(value, s->value); if (NULL != c) SET_DBL_RESULT(value, c->val[0]); return h->ret; }