static void entity_change(enum ipmi_update_e op, ipmi_domain_t *domain, ipmi_entity_t *entity, void *cb_data) { int ret; zbx_ipmi_host_t *h = cb_data; zabbix_log(LOG_LEVEL_DEBUG, "In entity_change()"); if (op == IPMI_ADDED) { if (0 != (ret = ipmi_entity_add_sensor_update_handler(entity, sensor_change, h))) zabbix_log(LOG_LEVEL_DEBUG, "ipmi_entity_set_sensor_update_handler() return error: 0x%x", ret); if (0 != (ret = ipmi_entity_add_control_update_handler(entity, control_change, h))) zabbix_log(LOG_LEVEL_DEBUG, "ipmi_entity_add_control_update_handler() return error: 0x%x", ret); } }
/* callback function invoked from OpenIPMI */ static void entity_change(enum ipmi_update_e op, ipmi_domain_t *domain, ipmi_entity_t *entity, void *cb_data) { const char *__function_name = "entity_change"; int ret; zbx_ipmi_host_t *h = cb_data; zabbix_log(LOG_LEVEL_DEBUG, "In %s() phost:%p host:'[%s]:%d'", __function_name, h, h->ip, h->port); if (op == IPMI_ADDED) { if (0 != (ret = ipmi_entity_add_sensor_update_handler(entity, sensor_change, h))) zabbix_log(LOG_LEVEL_DEBUG, "ipmi_entity_set_sensor_update_handler() return error: 0x%x", ret); if (0 != (ret = ipmi_entity_add_control_update_handler(entity, control_change, h))) zabbix_log(LOG_LEVEL_DEBUG, "ipmi_entity_add_control_update_handler() return error: 0x%x", ret); } zabbix_log(LOG_LEVEL_DEBUG, "End of %s()", __function_name); }
void ohoi_entity_event(enum ipmi_update_e op, ipmi_domain_t *domain, ipmi_entity_t *entity, void *cb_data) { struct oh_handler_state *handler = cb_data; struct ohoi_handler *ipmi_handler = handler->data; int rv; int inst=0; inst=ipmi_entity_get_entity_instance(entity); if(inst >=96) { inst = inst - 96; } g_static_rec_mutex_lock(&ipmi_handler->ohoih_lock); switch (op) { case IPMI_ADDED: add_entity_event(domain, entity, handler); trace_ipmi_entity("ADDED", inst, entity); /* entity presence overall */ rv = ipmi_entity_add_presence_handler(entity, entity_presence, handler); if (rv) dbg("ipmi_entity_set_presence_handler: %#x", rv); /* hotswap handler */ rv = ipmi_entity_add_hot_swap_handler(entity, ohoi_hot_swap_cb, cb_data); if(rv) dbg("Failed to set entity hot swap handler"); /* sensors */ rv= ipmi_entity_add_sensor_update_handler(entity, ohoi_sensor_event, handler); if (rv) { dbg("ipmi_entity_set_sensor_update_handler: %#x", rv); break; } /* controls */ rv = ipmi_entity_add_control_update_handler(entity, ohoi_control_event, handler); if (rv) { dbg("ipmi_entity_set_control_update_handler: %#x", rv); return; } /* inventory (a.k.a FRU) */ rv = ipmi_entity_add_fru_update_handler(entity, ohoi_inventory_event, handler); if (rv) { dbg("ipmi_entity_set_fru_update_handler: %#x", rv); break; } break; case IPMI_DELETED: delete_entity(handler, entity); trace_ipmi_entity("DELETED", inst, entity); break; case IPMI_CHANGED: change_entity(handler, entity); trace_ipmi_entity("CHANGED", inst, entity); break; default: dbg("Entity: Unknow change?!"); } g_static_rec_mutex_unlock(&ipmi_handler->ohoih_lock); }
void ohoi_entity_event(enum ipmi_update_e op, ipmi_domain_t *domain, ipmi_entity_t *entity, void *cb_data) { struct oh_handler_state *handler = cb_data; int rv; switch (op) { case IPMI_ADDED: add_entity_event(entity, handler); dbg("Entity added: %d.%d (%s)", ipmi_entity_get_entity_id(entity), ipmi_entity_get_entity_instance(entity), ipmi_entity_get_entity_id_string(entity)); /* entity presence overall */ rv = ipmi_entity_add_presence_handler(entity, entity_presence, handler); if (rv) dbg("ipmi_entity_set_presence_handler: %#x", rv); /* hotswap handler */ rv = ipmi_entity_add_hot_swap_handler(entity, ohoi_hot_swap_cb, cb_data); if(rv) dbg("Failed to set entity hot swap handler"); /* sensors */ rv= ipmi_entity_add_sensor_update_handler(entity, ohoi_sensor_event, handler); if (rv) { dbg("ipmi_entity_set_sensor_update_handler: %#x", rv); return; } /* controls */ rv = ipmi_entity_add_control_update_handler(entity, ohoi_control_event, handler); if (rv) { dbg("ipmi_entity_set_control_update_handler: %#x", rv); return; } /* inventory (a.k.a FRU) */ rv = ipmi_entity_add_fru_update_handler(entity, ohoi_inventory_event, handler); if (rv) { dbg("ipmi_entity_set_fru_update_handler: %#x", rv); return; } break; case IPMI_DELETED: return; /* we need to remove_entity */ dbg("Entity deleted: %d.%d", ipmi_entity_get_entity_id(entity), ipmi_entity_get_entity_instance(entity)); break; case IPMI_CHANGED: add_entity_event(entity, handler); dbg("Entity changed: %d.%d", ipmi_entity_get_entity_id(entity), ipmi_entity_get_entity_instance(entity)); break; default: dbg("Entity: Unknow change?!"); } }
static void get_entity_event(ipmi_entity_t *entity, SaHpiRptEntryT *entry, void *cb_data) { SaHpiEntityPathT entity_ep; struct oh_handler_state *handler = cb_data; struct ohoi_handler *ipmi_handler = handler->data; int er, i; int rv; const char *str; g_static_rec_mutex_lock(&ipmi_handler->ohoih_lock); entry->ResourceInfo.ResourceRev = 0; entry->ResourceInfo.SpecificVer = 0; entry->ResourceInfo.DeviceSupport = 0; entry->ResourceInfo.ManufacturerId = 0; entry->ResourceInfo.ProductId = 0; entry->ResourceInfo.FirmwareMajorRev = 0; entry->ResourceInfo.FirmwareMinorRev = 0; for (i=0; i<15; i++) { entry->ResourceInfo.Guid[i] = 0; } entry->ResourceInfo.AuxFirmwareRev = 0; entry->ResourceEntity.Entry[0].EntityType = ipmi_entity_get_entity_id(entity); entry->ResourceEntity.Entry[0].EntityLocation = ipmi_entity_get_entity_instance(entity); if(ipmi_entity_get_entity_instance(entity) >= 96) { entry->ResourceEntity.Entry[0].EntityLocation = ipmi_entity_get_entity_instance(entity)- 96; } entry->ResourceEntity.Entry[1].EntityType = SAHPI_ENT_ROOT; entry->ResourceEntity.Entry[1].EntityLocation = 0; entry->EntryId = 0; entry->ResourceId = oh_uid_from_entity_path(&entry->ResourceEntity); entry->ResourceCapabilities = SAHPI_CAPABILITY_RESOURCE; entry->HotSwapCapabilities = 0; if (ipmi_entity_supports_managed_hot_swap(entity)) { trace_ipmi("Entity is hot swapable"); entry->ResourceCapabilities |= SAHPI_CAPABILITY_MANAGED_HOTSWAP; /* if entity supports managed hot swap * check if it has indicator */ /* we need only return value from function */ er = ipmi_entity_get_hot_swap_indicator(entity, NULL, NULL); if (!er) { entry->HotSwapCapabilities |= SAHPI_HS_CAPABILITY_INDICATOR_SUPPORTED; } } /* OpenIPMI used ipmi_entity_hot_swappable to indicate it's FRU * do not use ipmi_entity_get_is_fru() * it's used only for checking if entity has FRU data */ if(ipmi_entity_hot_swappable(entity)) { trace_ipmi("Entity supports simplified hotswap"); entry->ResourceCapabilities |= SAHPI_CAPABILITY_FRU; } // if (ipmi_entity_get_is_fru(entity)) { // dbg("Entity supports FRU Inventory Data"); // entry->ResourceCapabilities |= SAHPI_CAPABILITY_INVENTORY_DATA; // } if (entry->ResourceEntity.Entry[0].EntityType == SAHPI_ENT_SYSTEM_BOARD) { /* This is the BMC entry, so we need to add watchdog. */ entry->ResourceCapabilities |= SAHPI_CAPABILITY_WATCHDOG; } entry->ResourceSeverity = SAHPI_MAJOR; /* Default Value -- not related to IPMI */ entry->ResourceFailed = SAHPI_FALSE; entry->ResourceTag.DataType = SAHPI_TL_TYPE_TEXT; entry->ResourceTag.Language = SAHPI_LANG_ENGLISH; //ipmi_entity_get_id(entity, entry->ResourceTag.Data, SAHPI_MAX_TEXT_BUFFER_LENGTH); str = ipmi_entity_get_entity_id_string(entity); memcpy(entry->ResourceTag.Data,str, strlen(str) +1); entry->ResourceTag.DataLength = strlen(entry->ResourceTag.Data); #if 0 if ((strlen(entry->ResourceTag.Data) == 0) || (!strcmp(entry->ResourceTag.Data, "invalid")) || ((ipmi_entity_get_entity_id(entity) == 7 || 15))) { const char *str; char *str2; int inst; inst = ipmi_entity_get_entity_instance(entity); if (inst >= 96) inst = inst - 96; str = ipmi_entity_get_entity_id_string(entity); if (!(strcmp(str, "invalid"))) { dbg("entity_id_string is invlaid, bad SDR..stick to entity_id"); } else { /* Let's identify the entity-instance in the ResourceTag */ dbg("Instance for ResourceTag %d", inst); str2 = (char *)calloc(strlen(str) + 4, sizeof(char)); snprintf(str2, strlen(str) + 4, "%s-%d",str, inst); memcpy(entry->ResourceTag.Data, str2, strlen(str2) + 1); } } /* AdvancedTCA fix-up */ /* Here we start dealing with device relative entities */ #endif #if 0 if (ipmi_entity_get_entity_instance(entity) >= 96) { entry->ResourceEntity.Entry[0].EntityLocation = ipmi_entity_get_entity_instance(entity) - 96; entry->ResourceEntity.Entry[0].EntityType = ipmi_entity_get_entity_id(entity); entry->ResourceEntity.Entry[1].EntityType = SAHPI_ENT_PHYSICAL_SLOT; int rv; unsigned int val; rv = ipmi_entity_get_physical_slot_num(entity, &val); if (rv != 0) { entry->ResourceEntity.Entry[1].EntityLocation = ipmi_entity_get_device_address(entity); } else { entry->ResourceEntity.Entry[1].EntityLocation = val; } entry->ResourceEntity.Entry[2].EntityType = SAHPI_ENT_ROOT; entry->ResourceEntity.Entry[2].EntityLocation = 0; } #endif /* Since OpenIPMI does not hand us a more descriptive tag which is an SDR issue inthe chassis really, we'll over-ride it here until things change */ if ((ipmi_entity_get_entity_id(entity) == 160) && (ipmi_entity_get_entity_instance(entity) >= 96)) { dbg("SBC Blade"); const char sbc_tag[] = "SBC Blade"; memcpy(entry->ResourceTag.Data, sbc_tag, strlen(sbc_tag) + 1); entry->ResourceEntity.Entry[0].EntityLocation = ipmi_entity_get_entity_instance(entity) - 96; entry->ResourceEntity.Entry[0].EntityType = SAHPI_ENT_SBC_BLADE; entry->ResourceEntity.Entry[1].EntityType = SAHPI_ENT_PHYSICAL_SLOT; unsigned int val; rv = ipmi_entity_get_physical_slot_num(entity, &val); if (rv != 0) { entry->ResourceEntity.Entry[1].EntityLocation = ipmi_entity_get_device_address(entity); dbg("Erro getting Physical Slot Number"); } else { dbg("Physical lot Num: %d", val); entry->ResourceEntity.Entry[1].EntityLocation = val; } entry->ResourceEntity.Entry[2].EntityType = SAHPI_ENT_ROOT; entry->ResourceEntity.Entry[2].EntityLocation = 0; } if ((ipmi_entity_get_entity_id(entity) == 160) && ((ipmi_entity_get_device_address(entity) == 130) || (ipmi_entity_get_device_address(entity) == 132))) { dbg("Switch Blade"); const char switch_tag[] = "Switch Blade"; memcpy(entry->ResourceTag.Data, switch_tag, strlen(switch_tag) + 1); entry->ResourceEntity.Entry[0].EntityLocation = ipmi_entity_get_entity_instance(entity) - 96; entry->ResourceEntity.Entry[0].EntityType = SAHPI_ENT_SWITCH_BLADE; entry->ResourceEntity.Entry[1].EntityType = SAHPI_ENT_PHYSICAL_SLOT; unsigned int val; rv = ipmi_entity_get_physical_slot_num(entity, &val); if (rv != 0) entry->ResourceEntity.Entry[1].EntityLocation = ipmi_entity_get_device_address(entity); else entry->ResourceEntity.Entry[1].EntityLocation = val; dbg("Physical lot Num: %d", val); entry->ResourceEntity.Entry[2].EntityType = SAHPI_ENT_ROOT; entry->ResourceEntity.Entry[2].EntityLocation = 0; } //if ((ipmi_entity_get_entity_id(entity) == 10)) { //dbg("PowerSupply Device"); //entry->ResourceEntity.Entry[1].EntityLocation = 0; //entry->ResourceEntity.Entry[1].EntityType = //SAHPI_ENT_POWER_UNIT; //} if ((ipmi_entity_get_entity_id(entity) == 30)) { dbg("Cooling Device"); //const char disk_tag[] = "Cooling Unit"; //memcpy(entry->ResourceTag.Data, disk_tag, strlen(disk_tag) + 1); entry->ResourceEntity.Entry[0].EntityLocation = ipmi_entity_get_entity_instance(entity) - 96; entry->ResourceEntity.Entry[0].EntityType = ipmi_entity_get_entity_id(entity); } /* this is here for Force-made Storage blades * until we have access to latest hardware * DO NOT CHANGE */ if ((ipmi_entity_get_entity_id(entity) == 160) && (ipmi_entity_get_entity_instance(entity) == 102)) { dbg("DISK Blade"); const char disk_tag[] = "Storage/Disk Blade"; memcpy(entry->ResourceTag.Data, disk_tag, strlen(disk_tag) + 1); //entry->ResourceEntity.Entry[0].EntityLocation = //ipmi_entity_get_entity_instance(entity) - 96; entry->ResourceEntity.Entry[0].EntityType = SAHPI_ENT_DISK_BLADE; } /* End AdvancedTCA Fix-ups */ entry->ResourceTag.DataLength = (SaHpiUint32T)strlen(entry->ResourceTag.Data); oh_encode_entitypath(ipmi_handler->entity_root, &entity_ep); oh_concat_ep(&entry->ResourceEntity, &entity_ep); entry->ResourceId = oh_uid_from_entity_path(&entry->ResourceEntity); trace_ipmi("ResourceId: %d", entry->ResourceId); /* controls */ rv = ipmi_entity_add_control_update_handler(entity, ohoi_control_event, handler); if (rv) { dbg("ipmi_entity_set_control_update_handler: %#x", rv); return; } g_static_rec_mutex_unlock(&ipmi_handler->ohoih_lock); }