/* * slurm_sprint_node_table - output information about a specific Slurm nodes * based upon message as loaded using slurm_load_node * IN node_ptr - an individual node information record pointer * IN node_scaling - number of nodes each node represents * IN one_liner - print as a single line if true * RET out - char * containing formatted output (must be freed after call) * NULL is returned on failure. */ char * slurm_sprint_node_table (node_info_t * node_ptr, int node_scaling, int one_liner ) { uint16_t my_state = node_ptr->node_state; char *cloud_str = "", *comp_str = "", *drain_str = "", *power_str = ""; char load_str[32], tmp_line[512], time_str[32]; char *out = NULL, *reason_str = NULL, *select_reason_str = NULL; uint16_t err_cpus = 0, alloc_cpus = 0; int cpus_per_node = 1; int total_used = node_ptr->cpus; uint32_t cluster_flags = slurmdb_setup_cluster_flags(); if (node_scaling) cpus_per_node = node_ptr->cpus / node_scaling; if (my_state & NODE_STATE_CLOUD) { my_state &= (~NODE_STATE_CLOUD); cloud_str = "+CLOUD"; } if (my_state & NODE_STATE_COMPLETING) { my_state &= (~NODE_STATE_COMPLETING); comp_str = "+COMPLETING"; } if (my_state & NODE_STATE_DRAIN) { my_state &= (~NODE_STATE_DRAIN); drain_str = "+DRAIN"; } if (my_state & NODE_STATE_POWER_SAVE) { my_state &= (~NODE_STATE_POWER_SAVE); power_str = "+POWER"; } slurm_get_select_nodeinfo(node_ptr->select_nodeinfo, SELECT_NODEDATA_SUBCNT, NODE_STATE_ALLOCATED, &alloc_cpus); if (cluster_flags & CLUSTER_FLAG_BG) { if (!alloc_cpus && (IS_NODE_ALLOCATED(node_ptr) || IS_NODE_COMPLETING(node_ptr))) alloc_cpus = node_ptr->cpus; else alloc_cpus *= cpus_per_node; } total_used -= alloc_cpus; slurm_get_select_nodeinfo(node_ptr->select_nodeinfo, SELECT_NODEDATA_SUBCNT, NODE_STATE_ERROR, &err_cpus); if (cluster_flags & CLUSTER_FLAG_BG) err_cpus *= cpus_per_node; total_used -= err_cpus; if ((alloc_cpus && err_cpus) || (total_used && (total_used != node_ptr->cpus))) { my_state &= NODE_STATE_FLAGS; my_state |= NODE_STATE_MIXED; } /****** Line 1 ******/ snprintf(tmp_line, sizeof(tmp_line), "NodeName=%s ", node_ptr->name); xstrcat(out, tmp_line); if (cluster_flags & CLUSTER_FLAG_BG) { slurm_get_select_nodeinfo(node_ptr->select_nodeinfo, SELECT_NODEDATA_RACK_MP, 0, &select_reason_str); if (select_reason_str) { xstrfmtcat(out, "RackMidplane=%s ", select_reason_str); xfree(select_reason_str); } } if (node_ptr->arch) { snprintf(tmp_line, sizeof(tmp_line), "Arch=%s ", node_ptr->arch); xstrcat(out, tmp_line); } snprintf(tmp_line, sizeof(tmp_line), "CoresPerSocket=%u", node_ptr->cores); xstrcat(out, tmp_line); if (one_liner) xstrcat(out, " "); else xstrcat(out, "\n "); /****** Line 2 ******/ if (node_ptr->cpu_load == NO_VAL) strcpy(load_str, "N/A"); else { snprintf(load_str, sizeof(load_str), "%.2f", (node_ptr->cpu_load / 100.0)); } snprintf(tmp_line, sizeof(tmp_line), "CPUAlloc=%u CPUErr=%u CPUTot=%u CPULoad=%s Features=%s", alloc_cpus, err_cpus, node_ptr->cpus, load_str, node_ptr->features); xstrcat(out, tmp_line); if (one_liner) xstrcat(out, " "); else xstrcat(out, "\n "); /****** Line 3 ******/ snprintf(tmp_line, sizeof(tmp_line), "Gres=%s",node_ptr->gres); xstrcat(out, tmp_line); if (one_liner) xstrcat(out, " "); else xstrcat(out, "\n "); /****** Line 4 (optional) ******/ if (node_ptr->node_hostname || node_ptr->node_addr) { snprintf(tmp_line, sizeof(tmp_line), "NodeAddr=%s NodeHostName=%s", node_ptr->node_addr, node_ptr->node_hostname); xstrcat(out, tmp_line); if (one_liner) xstrcat(out, " "); else xstrcat(out, "\n "); } /****** Line 5 ******/ if (node_ptr->os) { snprintf(tmp_line, sizeof(tmp_line), "OS=%s ", node_ptr->os); xstrcat(out, tmp_line); } snprintf(tmp_line, sizeof(tmp_line), "RealMemory=%u Sockets=%u Boards=%u", node_ptr->real_memory, node_ptr->sockets, node_ptr->boards); xstrcat(out, tmp_line); if (one_liner) xstrcat(out, " "); else xstrcat(out, "\n "); /****** Line 6 ******/ snprintf(tmp_line, sizeof(tmp_line), "State=%s%s%s%s%s ThreadsPerCore=%u TmpDisk=%u Weight=%u", node_state_string(my_state), cloud_str, comp_str, drain_str, power_str, node_ptr->threads, node_ptr->tmp_disk, node_ptr->weight); xstrcat(out, tmp_line); if (one_liner) xstrcat(out, " "); else xstrcat(out, "\n "); /****** Line 7 ******/ if (node_ptr->boot_time) { slurm_make_time_str ((time_t *)&node_ptr->boot_time, time_str, sizeof(time_str)); } else { strncpy(time_str, "None", sizeof(time_str)); } snprintf(tmp_line, sizeof(tmp_line), "BootTime=%s ", time_str); xstrcat(out, tmp_line); if (node_ptr->slurmd_start_time) { slurm_make_time_str ((time_t *)&node_ptr->slurmd_start_time, time_str, sizeof(time_str)); } else { strncpy(time_str, "None", sizeof(time_str)); } snprintf(tmp_line, sizeof(tmp_line), "SlurmdStartTime=%s", time_str); xstrcat(out, tmp_line); if (one_liner) xstrcat(out, " "); else xstrcat(out, "\n "); /****** power Line ******/ if (node_ptr->energy->current_watts == NO_VAL) snprintf(tmp_line, sizeof(tmp_line), "CurrentWatts=n/s " "LowestJoules=n/s ConsumedJoules=n/s"); else snprintf(tmp_line, sizeof(tmp_line), "CurrentWatts=%u " "LowestJoules=%u ConsumedJoules=%u", node_ptr->energy->current_watts, node_ptr->energy->base_watts, node_ptr->energy->consumed_energy); xstrcat(out, tmp_line); if (one_liner) xstrcat(out, " "); else xstrcat(out, "\n "); /****** Line 8 ******/ if (node_ptr->reason && node_ptr->reason[0]) xstrcat(reason_str, node_ptr->reason); slurm_get_select_nodeinfo(node_ptr->select_nodeinfo, SELECT_NODEDATA_EXTRA_INFO, 0, &select_reason_str); if (select_reason_str && select_reason_str[0]) { if (reason_str) xstrcat(reason_str, "\n"); xstrcat(reason_str, select_reason_str); } xfree(select_reason_str); if (reason_str) { int inx = 1; char *save_ptr = NULL, *tok, *user_name; tok = strtok_r(reason_str, "\n", &save_ptr); while (tok) { if (inx == 1) { xstrcat(out, "Reason="); } else { if (one_liner) xstrcat(out, " "); else xstrcat(out, "\n "); xstrcat(out, " "); } snprintf(tmp_line, sizeof(tmp_line), "%s", tok); xstrcat(out, tmp_line); if ((inx++ == 1) && node_ptr->reason_time) { user_name = uid_to_string(node_ptr->reason_uid); slurm_make_time_str((time_t *)&node_ptr->reason_time, time_str,sizeof(time_str)); snprintf(tmp_line, sizeof(tmp_line), " [%s@%s]", user_name, time_str); xstrcat(out, tmp_line); } tok = strtok_r(NULL, "\n", &save_ptr); } xfree(reason_str); } if (one_liner) xstrcat(out, "\n"); else xstrcat(out, "\n\n"); return out; }
/* * convert node_info_t to perl HV */ int node_info_to_hv(node_info_t *node_info, uint16_t node_scaling, HV *hv) { uint16_t err_cpus = 0, alloc_cpus = 0; #ifdef HAVE_BG int cpus_per_node = 1; if(node_scaling) cpus_per_node = node_info->cpus / node_scaling; #endif if(node_info->arch) STORE_FIELD(hv, node_info, arch, charp); STORE_FIELD(hv, node_info, boot_time, time_t); STORE_FIELD(hv, node_info, cores, uint16_t); STORE_FIELD(hv, node_info, cpu_load, uint32_t); STORE_FIELD(hv, node_info, cpus, uint16_t); if (node_info->features) STORE_FIELD(hv, node_info, features, charp); if (node_info->features_act) STORE_FIELD(hv, node_info, features_act, charp); if (node_info->gres) STORE_FIELD(hv, node_info, gres, charp); if (node_info->name) STORE_FIELD(hv, node_info, name, charp); else { Perl_warn (aTHX_ "node name missing in node_info_t"); return -1; } STORE_FIELD(hv, node_info, node_state, uint32_t); if(node_info->os) STORE_FIELD(hv, node_info, os, charp); STORE_FIELD(hv, node_info, real_memory, uint64_t); if(node_info->reason) STORE_FIELD(hv, node_info, reason, charp); STORE_FIELD(hv, node_info, reason_time, time_t); STORE_FIELD(hv, node_info, reason_uid, uint32_t); STORE_FIELD(hv, node_info, slurmd_start_time, time_t); STORE_FIELD(hv, node_info, boards, uint16_t); STORE_FIELD(hv, node_info, sockets, uint16_t); STORE_FIELD(hv, node_info, threads, uint16_t); STORE_FIELD(hv, node_info, tmp_disk, uint32_t); slurm_get_select_nodeinfo(node_info->select_nodeinfo, SELECT_NODEDATA_SUBCNT, NODE_STATE_ALLOCATED, &alloc_cpus); #ifdef HAVE_BG if(!alloc_cpus && (IS_NODE_ALLOCATED(node_info) || IS_NODE_COMPLETING(node_info))) alloc_cpus = node_info->cpus; else alloc_cpus *= cpus_per_node; #endif slurm_get_select_nodeinfo(node_info->select_nodeinfo, SELECT_NODEDATA_SUBCNT, NODE_STATE_ERROR, &err_cpus); #ifdef HAVE_BG err_cpus *= cpus_per_node; #endif hv_store_uint16_t(hv, "alloc_cpus", alloc_cpus); hv_store_uint16_t(hv, "err_cpus", err_cpus); STORE_PTR_FIELD(hv, node_info, select_nodeinfo, "Slurm::dynamic_plugin_data_t"); STORE_FIELD(hv, node_info, weight, uint32_t); return 0; }
/* * _filter_out - Determine if the specified node should be filtered out or * reported. * node_ptr IN - node to consider filtering out * RET - true if node should not be reported, false otherwise */ static bool _filter_out(node_info_t *node_ptr) { static hostlist_t host_list = NULL; if (params.nodes) { if (host_list == NULL) host_list = hostlist_create(params.nodes); if (hostlist_find (host_list, node_ptr->name) == -1) return true; } if (params.dead_nodes && !IS_NODE_NO_RESPOND(node_ptr)) return true; if (params.responding_nodes && IS_NODE_NO_RESPOND(node_ptr)) return true; if (params.state_list) { int *node_state; bool match = false; uint16_t base_state; ListIterator iterator; uint16_t cpus = 0; node_info_t tmp_node, *tmp_node_ptr = &tmp_node; iterator = list_iterator_create(params.state_list); while ((node_state = list_next(iterator))) { tmp_node_ptr->node_state = *node_state; if (*node_state == NODE_STATE_DRAIN) { /* We search for anything that has the * drain flag set */ if (IS_NODE_DRAIN(node_ptr)) { match = true; break; } } else if (IS_NODE_DRAINING(tmp_node_ptr)) { /* We search for anything that gets mapped to * DRAINING in node_state_string */ if (IS_NODE_DRAINING(node_ptr)) { match = true; break; } } else if (IS_NODE_DRAINED(tmp_node_ptr)) { /* We search for anything that gets mapped to * DRAINED in node_state_string */ if (IS_NODE_DRAINED(node_ptr)) { match = true; break; } } else if (*node_state & NODE_STATE_FLAGS) { if (*node_state & node_ptr->node_state) { match = true; break; } } else if (*node_state == NODE_STATE_ERROR) { slurm_get_select_nodeinfo( node_ptr->select_nodeinfo, SELECT_NODEDATA_SUBCNT, NODE_STATE_ERROR, &cpus); if (cpus) { match = true; break; } } else if (*node_state == NODE_STATE_ALLOCATED) { slurm_get_select_nodeinfo( node_ptr->select_nodeinfo, SELECT_NODEDATA_SUBCNT, NODE_STATE_ALLOCATED, &cpus); if (params.cluster_flags & CLUSTER_FLAG_BG && !cpus && (IS_NODE_ALLOCATED(node_ptr) || IS_NODE_COMPLETING(node_ptr))) cpus = node_ptr->cpus; if (cpus) { match = true; break; } } else if (*node_state == NODE_STATE_IDLE) { base_state = node_ptr->node_state & (~NODE_STATE_NO_RESPOND); if (base_state == NODE_STATE_IDLE) { match = true; break; } } else { base_state = node_ptr->node_state & NODE_STATE_BASE; if (base_state == *node_state) { match = true; break; } } } list_iterator_destroy(iterator); if (!match) return true; } return false; }
/* * slurm_sprint_node_table - output information about a specific Slurm nodes * based upon message as loaded using slurm_load_node * IN node_ptr - an individual node information record pointer * IN node_scaling - number of nodes each node represents * IN one_liner - print as a single line if true * RET out - char * containing formatted output (must be freed after call) * NULL is returned on failure. */ char * slurm_sprint_node_table (node_info_t * node_ptr, int node_scaling, int one_liner ) { uint32_t my_state = node_ptr->node_state; char *cloud_str = "", *comp_str = "", *drain_str = "", *power_str = ""; char time_str[32]; char *out = NULL, *reason_str = NULL, *select_reason_str = NULL; uint16_t err_cpus = 0, alloc_cpus = 0; int cpus_per_node = 1; int idle_cpus; uint32_t cluster_flags = slurmdb_setup_cluster_flags(); uint64_t alloc_memory; char *node_alloc_tres = NULL; char *line_end = (one_liner) ? " " : "\n "; if (node_scaling) cpus_per_node = node_ptr->cpus / node_scaling; if (my_state & NODE_STATE_CLOUD) { my_state &= (~NODE_STATE_CLOUD); cloud_str = "+CLOUD"; } if (my_state & NODE_STATE_COMPLETING) { my_state &= (~NODE_STATE_COMPLETING); comp_str = "+COMPLETING"; } if (my_state & NODE_STATE_DRAIN) { my_state &= (~NODE_STATE_DRAIN); drain_str = "+DRAIN"; } if (my_state & NODE_STATE_FAIL) { my_state &= (~NODE_STATE_FAIL); drain_str = "+FAIL"; } if (my_state & NODE_STATE_POWER_SAVE) { my_state &= (~NODE_STATE_POWER_SAVE); power_str = "+POWER"; } slurm_get_select_nodeinfo(node_ptr->select_nodeinfo, SELECT_NODEDATA_SUBCNT, NODE_STATE_ALLOCATED, &alloc_cpus); if (cluster_flags & CLUSTER_FLAG_BG) { if (!alloc_cpus && (IS_NODE_ALLOCATED(node_ptr) || IS_NODE_COMPLETING(node_ptr))) alloc_cpus = node_ptr->cpus; else alloc_cpus *= cpus_per_node; } idle_cpus = node_ptr->cpus - alloc_cpus; slurm_get_select_nodeinfo(node_ptr->select_nodeinfo, SELECT_NODEDATA_SUBCNT, NODE_STATE_ERROR, &err_cpus); if (cluster_flags & CLUSTER_FLAG_BG) err_cpus *= cpus_per_node; idle_cpus -= err_cpus; if ((alloc_cpus && err_cpus) || (idle_cpus && (idle_cpus != node_ptr->cpus))) { my_state &= NODE_STATE_FLAGS; my_state |= NODE_STATE_MIXED; } /****** Line 1 ******/ xstrfmtcat(out, "NodeName=%s ", node_ptr->name); if (cluster_flags & CLUSTER_FLAG_BG) { slurm_get_select_nodeinfo(node_ptr->select_nodeinfo, SELECT_NODEDATA_RACK_MP, 0, &select_reason_str); if (select_reason_str) { xstrfmtcat(out, "RackMidplane=%s ", select_reason_str); xfree(select_reason_str); } } if (node_ptr->arch) xstrfmtcat(out, "Arch=%s ", node_ptr->arch); xstrfmtcat(out, "CoresPerSocket=%u", node_ptr->cores); xstrcat(out, line_end); /****** Line ******/ xstrfmtcat(out, "CPUAlloc=%u CPUErr=%u CPUTot=%u ", alloc_cpus, err_cpus, node_ptr->cpus); if (node_ptr->cpu_load == NO_VAL) xstrcat(out, "CPULoad=N/A"); else xstrfmtcat(out, "CPULoad=%.2f", (node_ptr->cpu_load / 100.0)); xstrcat(out, line_end); /****** Line ******/ xstrfmtcat(out, "AvailableFeatures=%s", node_ptr->features); xstrcat(out, line_end); /****** Line ******/ xstrfmtcat(out, "ActiveFeatures=%s", node_ptr->features_act); xstrcat(out, line_end); /****** Line ******/ xstrfmtcat(out, "Gres=%s", node_ptr->gres); xstrcat(out, line_end); /****** Line (optional) ******/ if (node_ptr->gres_drain) { xstrfmtcat(out, "GresDrain=%s", node_ptr->gres_drain); xstrcat(out, line_end); } /****** Line (optional) ******/ if (node_ptr->gres_used) { xstrfmtcat(out, "GresUsed=%s", node_ptr->gres_used); xstrcat(out, line_end); } /****** Line (optional) ******/ if (node_ptr->node_hostname || node_ptr->node_addr) { xstrfmtcat(out, "NodeAddr=%s NodeHostName=%s Version=%s", node_ptr->node_addr, node_ptr->node_hostname, node_ptr->version); xstrcat(out, line_end); } /****** Line ******/ if (node_ptr->os) xstrfmtcat(out, "OS=%s ", node_ptr->os); slurm_get_select_nodeinfo(node_ptr->select_nodeinfo, SELECT_NODEDATA_MEM_ALLOC, NODE_STATE_ALLOCATED, &alloc_memory); xstrfmtcat(out, "RealMemory=%"PRIu64" AllocMem=%"PRIu64" ", node_ptr->real_memory, alloc_memory); if (node_ptr->free_mem == NO_VAL64) xstrcat(out, "FreeMem=N/A "); else xstrfmtcat(out, "FreeMem=%"PRIu64" ", node_ptr->free_mem); xstrfmtcat(out, "Sockets=%u Boards=%u", node_ptr->sockets, node_ptr->boards); xstrcat(out, line_end); /****** core & memory specialization Line (optional) ******/ if (node_ptr->core_spec_cnt || node_ptr->cpu_spec_list || node_ptr->mem_spec_limit) { if (node_ptr->core_spec_cnt) { xstrfmtcat(out, "CoreSpecCount=%u ", node_ptr->core_spec_cnt); } if (node_ptr->cpu_spec_list) { xstrfmtcat(out, "CPUSpecList=%s ", node_ptr->cpu_spec_list); } if (node_ptr->mem_spec_limit) { xstrfmtcat(out, "MemSpecLimit=%"PRIu64"", node_ptr->mem_spec_limit); } xstrcat(out, line_end); } /****** Line ******/ xstrfmtcat(out, "State=%s%s%s%s%s ThreadsPerCore=%u TmpDisk=%u Weight=%u ", node_state_string(my_state), cloud_str, comp_str, drain_str, power_str, node_ptr->threads, node_ptr->tmp_disk, node_ptr->weight); if (node_ptr->owner == NO_VAL) { xstrcat(out, "Owner=N/A "); } else { char *user_name = uid_to_string((uid_t) node_ptr->owner); xstrfmtcat(out, "Owner=%s(%u) ", user_name, node_ptr->owner); xfree(user_name); } xstrfmtcat(out, "MCS_label=%s", (node_ptr->mcs_label == NULL) ? "N/A" : node_ptr->mcs_label); xstrcat(out, line_end); /****** Line ******/ if (node_ptr->partitions) { xstrfmtcat(out, "Partitions=%s ", node_ptr->partitions); xstrcat(out, line_end); } /****** Line ******/ if (node_ptr->boot_time) { slurm_make_time_str((time_t *)&node_ptr->boot_time, time_str, sizeof(time_str)); xstrfmtcat(out, "BootTime=%s ", time_str); } else { xstrcat(out, "BootTime=None "); } if (node_ptr->slurmd_start_time) { slurm_make_time_str ((time_t *)&node_ptr->slurmd_start_time, time_str, sizeof(time_str)); xstrfmtcat(out, "SlurmdStartTime=%s", time_str); } else { xstrcat(out, "SlurmdStartTime=None"); } xstrcat(out, line_end); /****** TRES Line ******/ select_g_select_nodeinfo_get(node_ptr->select_nodeinfo, SELECT_NODEDATA_TRES_ALLOC_FMT_STR, NODE_STATE_ALLOCATED, &node_alloc_tres); xstrfmtcat(out, "CfgTRES=%s", node_ptr->tres_fmt_str); xstrcat(out, line_end); xstrfmtcat(out, "AllocTRES=%s", (node_alloc_tres) ? node_alloc_tres : ""); xfree(node_alloc_tres); xstrcat(out, line_end); /****** Power Management Line ******/ if (!node_ptr->power || (node_ptr->power->cap_watts == NO_VAL)) xstrcat(out, "CapWatts=n/a"); else xstrfmtcat(out, "CapWatts=%u", node_ptr->power->cap_watts); xstrcat(out, line_end); /****** Power Consumption Line ******/ if (!node_ptr->energy || node_ptr->energy->current_watts == NO_VAL) xstrcat(out, "CurrentWatts=n/s LowestJoules=n/s ConsumedJoules=n/s"); else xstrfmtcat(out, "CurrentWatts=%u " "LowestJoules=%"PRIu64" " "ConsumedJoules=%"PRIu64"", node_ptr->energy->current_watts, node_ptr->energy->base_consumed_energy, node_ptr->energy->consumed_energy); xstrcat(out, line_end); /****** external sensors Line ******/ if (!node_ptr->ext_sensors || node_ptr->ext_sensors->consumed_energy == NO_VAL) xstrcat(out, "ExtSensorsJoules=n/s "); else xstrfmtcat(out, "ExtSensorsJoules=%"PRIu64" ", node_ptr->ext_sensors->consumed_energy); if (!node_ptr->ext_sensors || node_ptr->ext_sensors->current_watts == NO_VAL) xstrcat(out, "ExtSensorsWatts=n/s "); else xstrfmtcat(out, "ExtSensorsWatts=%u ", node_ptr->ext_sensors->current_watts); if (!node_ptr->ext_sensors || node_ptr->ext_sensors->temperature == NO_VAL) xstrcat(out, "ExtSensorsTemp=n/s"); else xstrfmtcat(out, "ExtSensorsTemp=%u", node_ptr->ext_sensors->temperature); xstrcat(out, line_end); /****** Line ******/ if (node_ptr->reason && node_ptr->reason[0]) xstrcat(reason_str, node_ptr->reason); slurm_get_select_nodeinfo(node_ptr->select_nodeinfo, SELECT_NODEDATA_EXTRA_INFO, 0, &select_reason_str); if (select_reason_str && select_reason_str[0]) { if (reason_str) xstrcat(reason_str, "\n"); xstrcat(reason_str, select_reason_str); } xfree(select_reason_str); if (reason_str) { int inx = 1; char *save_ptr = NULL, *tok, *user_name; tok = strtok_r(reason_str, "\n", &save_ptr); while (tok) { if (inx == 1) { xstrcat(out, "Reason="); } else { xstrcat(out, line_end); xstrcat(out, " "); } xstrfmtcat(out, "%s", tok); if ((inx++ == 1) && node_ptr->reason_time) { user_name = uid_to_string(node_ptr->reason_uid); slurm_make_time_str((time_t *)&node_ptr->reason_time, time_str, sizeof(time_str)); xstrfmtcat(out, " [%s@%s]", user_name, time_str); xfree(user_name); } tok = strtok_r(NULL, "\n", &save_ptr); } xfree(reason_str); } if (one_liner) xstrcat(out, "\n"); else xstrcat(out, "\n\n"); return out; }
/* * slurm_sprint_node_table - output information about a specific Slurm nodes * based upon message as loaded using slurm_load_node * IN node_ptr - an individual node information record pointer * IN node_scaling - number of nodes each node represents * IN one_liner - print as a single line if true * RET out - char * containing formatted output (must be freed after call) * NULL is returned on failure. */ char * slurm_sprint_node_table (node_info_t * node_ptr, int node_scaling, int one_liner ) { uint16_t my_state = node_ptr->node_state; char *comp_str = "", *drain_str = "", *power_str = ""; char tmp_line[512], time_str[32]; char *out = NULL; uint16_t err_cpus = 0, alloc_cpus = 0; int cpus_per_node = 1; int total_used = node_ptr->cpus; uint32_t cluster_flags = slurmdb_setup_cluster_flags(); if (node_scaling) cpus_per_node = node_ptr->cpus / node_scaling; if (my_state & NODE_STATE_COMPLETING) { my_state &= (~NODE_STATE_COMPLETING); comp_str = "+COMPLETING"; } if (my_state & NODE_STATE_DRAIN) { my_state &= (~NODE_STATE_DRAIN); drain_str = "+DRAIN"; } if (my_state & NODE_STATE_POWER_SAVE) { my_state &= (~NODE_STATE_POWER_SAVE); power_str = "+POWER"; } slurm_get_select_nodeinfo(node_ptr->select_nodeinfo, SELECT_NODEDATA_SUBCNT, NODE_STATE_ALLOCATED, &alloc_cpus); if (cluster_flags & CLUSTER_FLAG_BG) { if (!alloc_cpus && (IS_NODE_ALLOCATED(node_ptr) || IS_NODE_COMPLETING(node_ptr))) alloc_cpus = node_ptr->cpus; else alloc_cpus *= cpus_per_node; } total_used -= alloc_cpus; slurm_get_select_nodeinfo(node_ptr->select_nodeinfo, SELECT_NODEDATA_SUBCNT, NODE_STATE_ERROR, &err_cpus); if (cluster_flags & CLUSTER_FLAG_BG) err_cpus *= cpus_per_node; total_used -= err_cpus; if ((alloc_cpus && err_cpus) || (total_used && (total_used != node_ptr->cpus))) { my_state &= NODE_STATE_FLAGS; my_state |= NODE_STATE_MIXED; } /****** Line 1 ******/ snprintf(tmp_line, sizeof(tmp_line), "NodeName=%s ", node_ptr->name); xstrcat(out, tmp_line); if (node_ptr->arch) { snprintf(tmp_line, sizeof(tmp_line), "Arch=%s ", node_ptr->arch); xstrcat(out, tmp_line); } snprintf(tmp_line, sizeof(tmp_line), "CoresPerSocket=%u", node_ptr->cores); xstrcat(out, tmp_line); if (one_liner) xstrcat(out, " "); else xstrcat(out, "\n "); /****** Line 2 ******/ snprintf(tmp_line, sizeof(tmp_line), "CPUAlloc=%u CPUErr=%u CPUTot=%u Features=%s", alloc_cpus, err_cpus, node_ptr->cpus, node_ptr->features); xstrcat(out, tmp_line); if (one_liner) xstrcat(out, " "); else xstrcat(out, "\n "); /****** Line 3 ******/ snprintf(tmp_line, sizeof(tmp_line), "Gres=%s",node_ptr->gres); xstrcat(out, tmp_line); if (one_liner) xstrcat(out, " "); else xstrcat(out, "\n "); /****** Line 4 (optional) ******/ if (node_ptr->node_hostname || node_ptr->node_addr) { snprintf(tmp_line, sizeof(tmp_line), "NodeAddr=%s NodeHostName=%s", node_ptr->node_addr, node_ptr->node_hostname); xstrcat(out, tmp_line); if (one_liner) xstrcat(out, " "); else xstrcat(out, "\n "); } /****** Line 5 ******/ if (node_ptr->os) { snprintf(tmp_line, sizeof(tmp_line), "OS=%s ", node_ptr->os); xstrcat(out, tmp_line); } snprintf(tmp_line, sizeof(tmp_line), "RealMemory=%u Sockets=%u", node_ptr->real_memory, node_ptr->sockets); xstrcat(out, tmp_line); if (one_liner) xstrcat(out, " "); else xstrcat(out, "\n "); /****** Line 6 ******/ snprintf(tmp_line, sizeof(tmp_line), "State=%s%s%s%s ThreadsPerCore=%u TmpDisk=%u Weight=%u", node_state_string(my_state), comp_str, drain_str, power_str, node_ptr->threads, node_ptr->tmp_disk, node_ptr->weight); xstrcat(out, tmp_line); if (one_liner) xstrcat(out, " "); else xstrcat(out, "\n "); /****** Line 7 ******/ if (node_ptr->boot_time) { slurm_make_time_str ((time_t *)&node_ptr->boot_time, time_str, sizeof(time_str)); } else { strncpy(time_str, "None", sizeof(time_str)); } snprintf(tmp_line, sizeof(tmp_line), "BootTime=%s ", time_str); xstrcat(out, tmp_line); if (node_ptr->slurmd_start_time) { slurm_make_time_str ((time_t *)&node_ptr->slurmd_start_time, time_str, sizeof(time_str)); } else { strncpy(time_str, "None", sizeof(time_str)); } snprintf(tmp_line, sizeof(tmp_line), "SlurmdStartTime=%s", time_str); xstrcat(out, tmp_line); if (one_liner) xstrcat(out, " "); else xstrcat(out, "\n "); /****** Line 8 ******/ if (node_ptr->reason_time) { char *user_name = uid_to_string(node_ptr->reason_uid); slurm_make_time_str ((time_t *)&node_ptr->reason_time, time_str, sizeof(time_str)); snprintf(tmp_line, sizeof(tmp_line), "Reason=%s [%s@%s]", node_ptr->reason, user_name, time_str); xstrcat(out, tmp_line); xfree(user_name); } else { snprintf(tmp_line, sizeof(tmp_line), "Reason=%s", node_ptr->reason); xstrcat(out, tmp_line); } if (one_liner) xstrcat(out, "\n"); else xstrcat(out, "\n\n"); return out; }
/* * slurm_sprint_node_table - output information about a specific Slurm nodes * based upon message as loaded using slurm_load_node * IN node_ptr - an individual node information record pointer * IN one_liner - print as a single line if true * RET out - char * containing formatted output (must be freed after call) * NULL is returned on failure. */ char *slurm_sprint_node_table(node_info_t *node_ptr, int one_liner) { uint32_t my_state = node_ptr->node_state; char *cloud_str = "", *comp_str = "", *drain_str = "", *power_str = ""; char time_str[32]; char *out = NULL, *reason_str = NULL; uint16_t alloc_cpus = 0; int idle_cpus; uint64_t alloc_memory; char *node_alloc_tres = NULL; char *line_end = (one_liner) ? " " : "\n "; slurm_ctl_conf_info_msg_t *slurm_ctl_conf_ptr = NULL; if (slurm_load_ctl_conf((time_t) NULL, &slurm_ctl_conf_ptr) != SLURM_SUCCESS) fatal("Cannot load slurmctld conf file"); if (my_state & NODE_STATE_CLOUD) { my_state &= (~NODE_STATE_CLOUD); cloud_str = "+CLOUD"; } if (my_state & NODE_STATE_COMPLETING) { my_state &= (~NODE_STATE_COMPLETING); comp_str = "+COMPLETING"; } if (my_state & NODE_STATE_DRAIN) { my_state &= (~NODE_STATE_DRAIN); drain_str = "+DRAIN"; } if (my_state & NODE_STATE_FAIL) { my_state &= (~NODE_STATE_FAIL); drain_str = "+FAIL"; } if (my_state & NODE_STATE_POWER_SAVE) { my_state &= (~NODE_STATE_POWER_SAVE); power_str = "+POWER"; } if (my_state & NODE_STATE_POWERING_DOWN) { my_state &= (~NODE_STATE_POWERING_DOWN); power_str = "+POWERING_DOWN"; } slurm_get_select_nodeinfo(node_ptr->select_nodeinfo, SELECT_NODEDATA_SUBCNT, NODE_STATE_ALLOCATED, &alloc_cpus); idle_cpus = node_ptr->cpus - alloc_cpus; if (idle_cpus && (idle_cpus != node_ptr->cpus)) { my_state &= NODE_STATE_FLAGS; my_state |= NODE_STATE_MIXED; } /****** Line 1 ******/ xstrfmtcat(out, "NodeName=%s ", node_ptr->name); if (node_ptr->arch) xstrfmtcat(out, "Arch=%s ", node_ptr->arch); if (node_ptr->cpu_bind) { char tmp_str[128]; slurm_sprint_cpu_bind_type(tmp_str, node_ptr->cpu_bind); xstrfmtcat(out, "CpuBind=%s ", tmp_str); } xstrfmtcat(out, "CoresPerSocket=%u ", node_ptr->cores); xstrcat(out, line_end); /****** Line ******/ xstrfmtcat(out, "CPUAlloc=%u CPUTot=%u ", alloc_cpus, node_ptr->cpus); if (node_ptr->cpu_load == NO_VAL) xstrcat(out, "CPULoad=N/A"); else xstrfmtcat(out, "CPULoad=%.2f", (node_ptr->cpu_load / 100.0)); xstrcat(out, line_end); /****** Line ******/ xstrfmtcat(out, "AvailableFeatures=%s", node_ptr->features); xstrcat(out, line_end); /****** Line ******/ xstrfmtcat(out, "ActiveFeatures=%s", node_ptr->features_act); xstrcat(out, line_end); /****** Line ******/ xstrfmtcat(out, "Gres=%s", node_ptr->gres); xstrcat(out, line_end); /****** Line (optional) ******/ if (node_ptr->gres_drain) { xstrfmtcat(out, "GresDrain=%s", node_ptr->gres_drain); xstrcat(out, line_end); } /****** Line (optional) ******/ if (node_ptr->gres_used) { xstrfmtcat(out, "GresUsed=%s", node_ptr->gres_used); xstrcat(out, line_end); } /****** Line (optional) ******/ { bool line_used = false; if (node_ptr->node_addr) { xstrfmtcat(out, "NodeAddr=%s ", node_ptr->node_addr); line_used = true; } if (node_ptr->node_hostname) { xstrfmtcat(out, "NodeHostName=%s ", node_ptr->node_hostname); line_used = true; } if (node_ptr->port != slurm_get_slurmd_port()) { xstrfmtcat(out, "Port=%u ", node_ptr->port); line_used = true; } if (node_ptr->version && xstrcmp(node_ptr->version, slurm_ctl_conf_ptr->version)) { xstrfmtcat(out, "Version=%s", node_ptr->version); line_used = true; } if (line_used) xstrcat(out, line_end); } /****** Line ******/ if (node_ptr->os) { xstrfmtcat(out, "OS=%s ", node_ptr->os); xstrcat(out, line_end); } /****** Line ******/ slurm_get_select_nodeinfo(node_ptr->select_nodeinfo, SELECT_NODEDATA_MEM_ALLOC, NODE_STATE_ALLOCATED, &alloc_memory); xstrfmtcat(out, "RealMemory=%"PRIu64" AllocMem=%"PRIu64" ", node_ptr->real_memory, alloc_memory); if (node_ptr->free_mem == NO_VAL64) xstrcat(out, "FreeMem=N/A "); else xstrfmtcat(out, "FreeMem=%"PRIu64" ", node_ptr->free_mem); xstrfmtcat(out, "Sockets=%u Boards=%u", node_ptr->sockets, node_ptr->boards); xstrcat(out, line_end); /****** core & memory specialization Line (optional) ******/ if (node_ptr->core_spec_cnt || node_ptr->cpu_spec_list || node_ptr->mem_spec_limit) { if (node_ptr->core_spec_cnt) { xstrfmtcat(out, "CoreSpecCount=%u ", node_ptr->core_spec_cnt); } if (node_ptr->cpu_spec_list) { xstrfmtcat(out, "CPUSpecList=%s ", node_ptr->cpu_spec_list); } if (node_ptr->mem_spec_limit) { xstrfmtcat(out, "MemSpecLimit=%"PRIu64"", node_ptr->mem_spec_limit); } xstrcat(out, line_end); } /****** Line ******/ xstrfmtcat(out, "State=%s%s%s%s%s ThreadsPerCore=%u TmpDisk=%u Weight=%u ", node_state_string(my_state), cloud_str, comp_str, drain_str, power_str, node_ptr->threads, node_ptr->tmp_disk, node_ptr->weight); if (node_ptr->owner == NO_VAL) { xstrcat(out, "Owner=N/A "); } else { char *user_name = uid_to_string((uid_t) node_ptr->owner); xstrfmtcat(out, "Owner=%s(%u) ", user_name, node_ptr->owner); xfree(user_name); } xstrfmtcat(out, "MCS_label=%s", (node_ptr->mcs_label == NULL) ? "N/A" : node_ptr->mcs_label); xstrcat(out, line_end); /****** Line ******/ if ((node_ptr->next_state != NO_VAL) && (my_state & NODE_STATE_REBOOT)) { xstrfmtcat(out, "NextState=%s", node_state_string(node_ptr->next_state)); xstrcat(out, line_end); } /****** Line ******/ if (node_ptr->partitions) { xstrfmtcat(out, "Partitions=%s ", node_ptr->partitions); xstrcat(out, line_end); } /****** Line ******/ if (node_ptr->boot_time) { slurm_make_time_str((time_t *)&node_ptr->boot_time, time_str, sizeof(time_str)); xstrfmtcat(out, "BootTime=%s ", time_str); } else { xstrcat(out, "BootTime=None "); } if (node_ptr->slurmd_start_time) { slurm_make_time_str ((time_t *)&node_ptr->slurmd_start_time, time_str, sizeof(time_str)); xstrfmtcat(out, "SlurmdStartTime=%s", time_str); } else { xstrcat(out, "SlurmdStartTime=None"); } xstrcat(out, line_end); /****** TRES Line ******/ select_g_select_nodeinfo_get(node_ptr->select_nodeinfo, SELECT_NODEDATA_TRES_ALLOC_FMT_STR, NODE_STATE_ALLOCATED, &node_alloc_tres); xstrfmtcat(out, "CfgTRES=%s", node_ptr->tres_fmt_str); xstrcat(out, line_end); xstrfmtcat(out, "AllocTRES=%s", (node_alloc_tres) ? node_alloc_tres : ""); xfree(node_alloc_tres); xstrcat(out, line_end); /****** Power Management Line ******/ if (!node_ptr->power || (node_ptr->power->cap_watts == NO_VAL)) xstrcat(out, "CapWatts=n/a"); else xstrfmtcat(out, "CapWatts=%u", node_ptr->power->cap_watts); xstrcat(out, line_end); /****** Power Consumption Line ******/ if (!node_ptr->energy || node_ptr->energy->current_watts == NO_VAL) xstrcat(out, "CurrentWatts=n/s AveWatts=n/s"); else xstrfmtcat(out, "CurrentWatts=%u AveWatts=%u", node_ptr->energy->current_watts, node_ptr->energy->ave_watts); xstrcat(out, line_end); /****** external sensors Line ******/ if (!node_ptr->ext_sensors || node_ptr->ext_sensors->consumed_energy == NO_VAL64) xstrcat(out, "ExtSensorsJoules=n/s "); else xstrfmtcat(out, "ExtSensorsJoules=%"PRIu64" ", node_ptr->ext_sensors->consumed_energy); if (!node_ptr->ext_sensors || node_ptr->ext_sensors->current_watts == NO_VAL) xstrcat(out, "ExtSensorsWatts=n/s "); else xstrfmtcat(out, "ExtSensorsWatts=%u ", node_ptr->ext_sensors->current_watts); if (!node_ptr->ext_sensors || node_ptr->ext_sensors->temperature == NO_VAL) xstrcat(out, "ExtSensorsTemp=n/s"); else xstrfmtcat(out, "ExtSensorsTemp=%u", node_ptr->ext_sensors->temperature); xstrcat(out, line_end); /****** Line ******/ if (node_ptr->reason && node_ptr->reason[0]) xstrcat(reason_str, node_ptr->reason); if (reason_str) { int inx = 1; char *save_ptr = NULL, *tok, *user_name; tok = strtok_r(reason_str, "\n", &save_ptr); while (tok) { if (inx == 1) { xstrcat(out, "Reason="); } else { xstrcat(out, line_end); xstrcat(out, " "); } xstrfmtcat(out, "%s", tok); if ((inx++ == 1) && node_ptr->reason_time) { user_name = uid_to_string(node_ptr->reason_uid); slurm_make_time_str((time_t *)&node_ptr->reason_time, time_str, sizeof(time_str)); xstrfmtcat(out, " [%s@%s]", user_name, time_str); xfree(user_name); } tok = strtok_r(NULL, "\n", &save_ptr); } xfree(reason_str); } if (one_liner) xstrcat(out, "\n"); else xstrcat(out, "\n\n"); slurm_free_ctl_conf(slurm_ctl_conf_ptr); return out; }
extern char *resolve_mp(char *desc, node_info_msg_t *node_info_ptr) { char *ret_str = NULL; #if defined HAVE_BG_FILES ba_mp_t *ba_mp = NULL; int i, start_pos; char *name; if (!desc) { ret_str = xstrdup("No Description given.\n"); goto fini; } start_pos = strlen(desc) - params.cluster_dims; if (start_pos < 0) { ret_str = xstrdup_printf("Must enter %d coords to resolve.\n", params.cluster_dims); goto fini; } if (desc[0] != 'R') name = desc+start_pos; else name = desc; if (node_info_ptr) { for (i=0; i<node_info_ptr->record_count; i++) { char *rack_mid, *node_geo; node_info_t *node_ptr = &(node_info_ptr->node_array[i]); if (!node_ptr->name || (node_ptr->name[0] == '\0')) continue; start_pos = strlen(node_ptr->name) - params.cluster_dims; node_geo = node_ptr->name+start_pos; slurm_get_select_nodeinfo(node_ptr->select_nodeinfo, SELECT_NODEDATA_RACK_MP, 0, &rack_mid); if (!rack_mid) break; if (desc[0] != 'R') { if (!xstrcasecmp(name, node_geo)) ret_str = xstrdup_printf( "%s resolves to %s\n", node_geo, rack_mid); } else if (!xstrcasecmp(name, rack_mid)) ret_str = xstrdup_printf( "%s resolves to %s\n", rack_mid, node_geo); xfree(rack_mid); if (ret_str) return ret_str; } if (desc[0] != 'R') ret_str = xstrdup_printf("%s has no resolve\n", name); else ret_str = xstrdup_printf("%s has no resolve.\n", desc); return ret_str; } /* Quite any errors that could come our way here. */ ba_configure_set_ba_debug_flags(0); bg_configure_ba_setup_wires(); if (desc[0] != 'R') { ba_mp = bg_configure_str2ba_mp(name); if (ba_mp) ret_str = xstrdup_printf("%s resolves to %s\n", ba_mp->coord_str, ba_mp->loc); else ret_str = xstrdup_printf("%s has no resolve\n", name); } else { ba_mp = bg_configure_loc2ba_mp(desc); if (ba_mp) ret_str = xstrdup_printf("%s resolves to %s\n", desc, ba_mp->coord_str); else ret_str = xstrdup_printf("%s has no resolve.\n", desc); } fini: #else ret_str = xstrdup("Must be physically on a BlueGene system for support " "of resolve option.\n"); #endif return ret_str; }