--- src/zabbix_server/ipmi/checks_ipmi.c 2018-02-13 11:52:50.867463154 +0100 +++ src/zabbix_server/ipmi/checks_ipmi.c 2018-02-13 12:38:32.104415709 +0100 @@ -65,6 +65,7 @@ /* Discrete, 'digital' Discrete. */ int type; /* "Sensor Type Code", e.g. Temperature, Voltage, */ /* Current, Fan, Physical Security (Chassis Intrusion), etc. */ + char *full_name; /* Full name of the sensor */ } zbx_ipmi_sensor_t; @@ -276,6 +277,28 @@ return s; } +static zbx_ipmi_sensor_t *zbx_get_ipmi_sensor_by_full_name(zbx_ipmi_host_t *h, const char *full_name) +{ + const char *__function_name = "zbx_get_ipmi_sensor_by_full_name"; + int i; + zbx_ipmi_sensor_t *s = NULL; + + zabbix_log(LOG_LEVEL_DEBUG, "In %s() sensor:'%s@[%s]:%d", __function_name, full_name, h->ip, h->port); + + for (i = 0; i < h->sensor_count; i++) + { + if (0 == strcmp(h->sensors[i].full_name, full_name)) + { + s = &h->sensors[i]; + break; + } + } + + zabbix_log(LOG_LEVEL_DEBUG, "End of %s():%p", __function_name, s); + + return s; +} + static zbx_ipmi_sensor_t *zbx_allocate_ipmi_sensor(zbx_ipmi_host_t *h, ipmi_sensor_t *sensor) { const char *__function_name = "zbx_allocate_ipmi_sensor"; @@ -284,7 +307,9 @@ char id[IPMI_SENSOR_ID_SZ]; enum ipmi_str_type_e id_type; int id_sz; - size_t sz; + size_t sz, sz2; + char domain_name[11]; /* max int length */ + char full_name[MAX_STRING_LEN]; id_sz = ipmi_sensor_get_id_length(sensor); memset(id, 0, sizeof(id)); @@ -311,17 +336,30 @@ s->reading_type = ipmi_sensor_get_event_reading_type(sensor); s->type = ipmi_sensor_get_sensor_type(sensor); - if (SUCCEED == zabbix_check_log_level(LOG_LEVEL_DEBUG)) + zbx_snprintf(domain_name, sizeof(domain_name), "%u", h->domain_nr); + ipmi_sensor_get_name(s->sensor, full_name, sizeof(full_name)); + sz = strlen(full_name); + sz2 = strlen(domain_name); + if ((sz > sz2) && !strncmp(domain_name, full_name, sz2)) { - char full_name[MAX_STRING_LEN]; - - ipmi_sensor_get_name(s->sensor, full_name, sizeof(full_name)); + // full name is prefixed by domain name + s->full_name = zbx_malloc(NULL, sz - sz2 + 1); + memcpy(s->full_name, full_name + sz2, sz - sz2 + 1); + } + else + { + // full name is NOT prefixed by domain name (normally should not happen) + s->full_name = zbx_malloc(NULL, sz + 1); + memcpy(s->full_name, full_name, sz + 1); + } + if (SUCCEED == zabbix_check_log_level(LOG_LEVEL_DEBUG)) + { zabbix_log(LOG_LEVEL_DEBUG, "Added sensor: host:'%s:%d' id_type:%d id_sz:%d id:'%s'" - " reading_type:0x%x ('%s') type:0x%x ('%s') full_name:'%s'", h->ip, h->port, + " reading_type:0x%x ('%s') type:0x%x ('%s') domain:'%s' full_name:'%s'", h->ip, h->port, s->id_type, s->id_sz, zbx_sensor_id_to_str(id_str, sizeof(id_str), s->id, s->id_type, s->id_sz), s->reading_type, ipmi_sensor_get_event_reading_type_string(s->sensor), - s->type, ipmi_sensor_get_sensor_type_string(s->sensor), full_name); + s->type, ipmi_sensor_get_sensor_type_string(s->sensor), domain_name, s->full_name); } zabbix_log(LOG_LEVEL_DEBUG, "End of %s():%p", __function_name, s); @@ -349,6 +387,8 @@ zbx_sensor_id_to_str(id_str, sizeof(id_str), h->sensors[i].id, h->sensors[i].id_type, h->sensors[i].id_sz), h->ip, h->port); + zbx_free(h->sensors[i].full_name); + h->sensor_count--; if (h->sensor_count != i) memmove(&h->sensors[i], &h->sensors[i + 1], sz * (size_t)(h->sensor_count - i)); @@ -1467,6 +1507,8 @@ s = zbx_get_ipmi_sensor_by_id(h, sensor); if (NULL == s) + s = zbx_get_ipmi_sensor_by_full_name(h, sensor); + if (NULL == s) c = zbx_get_ipmi_control_by_name(h, sensor); if (NULL == s && NULL == c)