/* * _thread_init initializes values and conf for the ipmi thread */ static int _thread_init(void) { static bool first = true; static int first_init = SLURM_ERROR; /* * If we are here we are a new slurmd thread serving * a request. In that case we must init a new ipmi_ctx, * update the sensor and return because the freeipmi lib * context cannot be shared among threads. */ if (_init_ipmi_config() != SLURM_SUCCESS) if (debug_flags & DEBUG_FLAG_ENERGY) { info("%s thread init error on _init_ipmi_config()", plugin_name); goto cleanup; } if (!first) return first_init; first = false; if (debug_flags & DEBUG_FLAG_ENERGY) info("%s thread init success", plugin_name); first_init = SLURM_SUCCESS; return SLURM_SUCCESS; cleanup: info("%s thread init error", plugin_name); first_init = SLURM_ERROR; return SLURM_ERROR; }
int main (int argc, char **argv) { struct ipmi_monitoring_ipmi_config ipmi_config; _init_ipmi_config (&ipmi_config); if (_ipmimonitoring (&ipmi_config) < 0) exit (1); exit (0); }
/* * _thread_init initializes values and conf for the ipmi thread */ static int _thread_init(void) { static bool first = true; int rc = SLURM_SUCCESS; if (!first) return rc; first = false; if (_init_ipmi_config() != SLURM_SUCCESS) { //TODO verbose error? rc = SLURM_FAILURE; } else { if ((slurm_ipmi_conf.power_sensor_num == -1 && _find_power_sensor() != SLURM_SUCCESS) || _check_power_sensor() != SLURM_SUCCESS) { local_energy->current_watts = NO_VAL; } else { local_energy->current_watts = last_update_watt; } if (slurm_ipmi_conf.reread_sdr_cache) //IPMI cache is reread only on initialisation //This option need a big EnergyIPMITimeout sensor_reading_flags ^= IPMI_MONITORING_SENSOR_READING_FLAGS_REREAD_SDR_CACHE; } local_energy->consumed_energy = 0; local_energy->base_watts = 0; slurm_mutex_unlock(&ipmi_mutex); if (rc != SLURM_SUCCESS) if (ipmi_ctx) ipmi_monitoring_ctx_destroy(ipmi_ctx); if (debug_flags & DEBUG_FLAG_ENERGY) info("%s thread init", plugin_name); return rc; }