static void _build_tres_list(void) { ListIterator iter; slurmdb_tres_rec_t *tres; char *tres_tmp = NULL, *tres_tmp2 = NULL, *save_ptr = NULL, *tok; if (!g_tres_list) { slurmdb_tres_cond_t cond = {0}; g_tres_list = slurmdb_tres_get(db_conn, &cond); if (!g_tres_list) { fatal("Problem getting TRES data: %m"); exit(1); } } FREE_NULL_LIST(tres_list); tres_list = list_create(slurmdb_destroy_tres_rec); if (!tres_str) { int tres_cpu_id = TRES_CPU; slurmdb_tres_rec_t *tres2; if (!(tres = list_find_first(g_tres_list, slurmdb_find_tres_in_list, &tres_cpu_id))) fatal("Failed to find CPU TRES!"); tres2 = slurmdb_copy_tres_rec(tres); list_append(tres_list, tres2); return; } tres_usage_str = "TRES"; iter = list_iterator_create(g_tres_list); while ((tres = list_next(iter))) { tres_tmp = xstrdup(tres_str); xstrfmtcat(tres_tmp2, "%s%s%s", tres->type, tres->name ? "/" : "", tres->name ? tres->name : ""); tok = strtok_r(tres_tmp, ",", &save_ptr); while (tok) { if (!xstrcasecmp(tres_tmp2, tok)) break; tok = strtok_r(NULL, ",", &save_ptr); } if (tok) { slurmdb_tres_rec_t *tres2 = slurmdb_copy_tres_rec(tres); list_append(tres_list, tres2); } xfree(tres_tmp2); xfree(tres_tmp); } if (!list_count(tres_list)) fatal("No valid TRES given"); list_iterator_destroy(iter); }
/* sacctmgr_list_tres() */ int sacctmgr_list_tres(int argc, char **argv) { List tres_list; ListIterator itr; ListIterator itr2; List format_list = list_create(slurm_destroy_char); List print_fields_list; slurmdb_tres_cond_t *tres_cond = xmalloc(sizeof(slurmdb_tres_cond_t)); slurmdb_tres_rec_t *tres; int field_count, i; print_field_t *field; for (i=0; i<argc; i++) { int command_len = strlen(argv[i]); if (!xstrncasecmp(argv[i], "Where", MAX(command_len, 5)) || !xstrncasecmp(argv[i], "Set", MAX(command_len, 3))) i++; _set_cond(&i, argc, argv, tres_cond, format_list); } if (exit_code) { slurmdb_destroy_tres_cond(tres_cond); FREE_NULL_LIST(format_list); return SLURM_ERROR; } if (!list_count(format_list)) { /* Append to the format list the fields * we want to print, these are the data structure * members of the type returned by slurmdbd */ slurm_addto_char_list(format_list, "Type,Name%15,ID"); } tres_list = slurmdb_tres_get(db_conn, tres_cond); slurmdb_destroy_tres_cond(tres_cond); if (!tres_list) { exit_code=1; fprintf(stderr, " Problem with query.\n"); FREE_NULL_LIST(format_list); return SLURM_ERROR; } /* Process the format list creating a list of * print field_t structures */ print_fields_list = sacctmgr_process_format_list(format_list); FREE_NULL_LIST(format_list); itr = list_iterator_create(tres_list); itr2 = list_iterator_create(print_fields_list); print_fields_header(print_fields_list); field_count = list_count(print_fields_list); /* For each tres prints the data structure members */ while ((tres = list_next(itr))) { while ((field = list_next(itr2))) { switch (field->type) { case PRINT_NAME: field->print_routine(field, tres->name, field_count); break; case PRINT_ID: field->print_routine(field, tres->id, field_count); break; case PRINT_TYPE: field->print_routine(field, tres->type, field_count); break; } } list_iterator_reset(itr2); printf("\n"); } list_iterator_destroy(itr); list_iterator_destroy(itr2); FREE_NULL_LIST(tres_list); FREE_NULL_LIST(print_fields_list); return 0; }
/* sacctmgr_list_reservation() */ int sacctmgr_list_reservation(int argc, char **argv) { List reservation_list; ListIterator itr; ListIterator itr2; List format_list = list_create(slurm_destroy_char); List print_fields_list; slurmdb_reservation_cond_t *reservation_cond = xmalloc(sizeof(slurmdb_reservation_cond_t)); slurmdb_reservation_rec_t *reservation; int field_count, i; print_field_t *field; char *tmp_char; /* If we don't have any arguments make sure we set up the time correctly for just the past day. */ if (argc == 0) { struct tm start_tm; reservation_cond->time_start = time(NULL); if (!slurm_localtime_r(&reservation_cond->time_start, &start_tm)) { fprintf(stderr, " Couldn't get localtime from %ld", (long)reservation_cond->time_start); exit_code = 1; return 0; } start_tm.tm_sec = 0; start_tm.tm_min = 0; start_tm.tm_hour = 0; start_tm.tm_mday--; start_tm.tm_isdst = -1; reservation_cond->time_start = slurm_mktime(&start_tm); } for (i=0; i<argc; i++) { int command_len = strlen(argv[i]); if (!strncasecmp(argv[i], "Where", MAX(command_len, 5)) || !strncasecmp(argv[i], "Set", MAX(command_len, 3))) i++; _set_cond(&i, argc, argv, reservation_cond, format_list); } if (exit_code) { slurmdb_destroy_reservation_cond(reservation_cond); FREE_NULL_LIST(format_list); return SLURM_ERROR; } if (!list_count(format_list)) { /* Append to the format list the fields * we want to print, these are the data structure * members of the type returned by slurmdbd */ slurm_addto_char_list(format_list, "Cluster,Name%15,TRES%30," "TimeStart,TimeEnd"); } reservation_list = acct_storage_g_get_reservations( db_conn, my_uid, reservation_cond); slurmdb_destroy_reservation_cond(reservation_cond); if (!reservation_list) { exit_code=1; fprintf(stderr, " Problem with query.\n"); FREE_NULL_LIST(format_list); return SLURM_ERROR; } /* Process the format list creating a list of * print field_t structures */ print_fields_list = sacctmgr_process_format_list(format_list); FREE_NULL_LIST(format_list); itr = list_iterator_create(reservation_list); itr2 = list_iterator_create(print_fields_list); print_fields_header(print_fields_list); field_count = list_count(print_fields_list); /* For each reservation prints the data structure members */ while ((reservation = list_next(itr))) { while ((field = list_next(itr2))) { switch (field->type) { case PRINT_ASSOC_NAME: field->print_routine( field, reservation->assocs, field_count); break; case PRINT_CLUSTER: field->print_routine( field, reservation->cluster, field_count); break; case PRINT_FLAGS: tmp_char = reservation_flags_string( reservation->flags); field->print_routine( field, tmp_char, field_count); xfree(tmp_char); break; case PRINT_ID: field->print_routine(field, reservation->id, field_count); break; case PRINT_NAME: field->print_routine(field, reservation->name, field_count); break; case PRINT_NODENAME: field->print_routine( field, reservation->nodes, field_count); break; case PRINT_TIMEEND: field->print_routine( field, reservation->time_end, field_count); break; case PRINT_TIMESTART: field->print_routine( field, reservation->time_start, field_count); break; case PRINT_TRES: if (!g_tres_list) { slurmdb_tres_cond_t tres_cond; memset(&tres_cond, 0, sizeof(slurmdb_tres_cond_t)); tres_cond.with_deleted = 1; g_tres_list = slurmdb_tres_get( db_conn, &tres_cond); } tmp_char = slurmdb_make_tres_string_from_simple( reservation->tres_str, g_tres_list); field->print_routine(field, tmp_char, field_count); xfree(tmp_char); break; } } list_iterator_reset(itr2); printf("\n"); } list_iterator_destroy(itr); list_iterator_destroy(itr2); FREE_NULL_LIST(reservation_list); FREE_NULL_LIST(print_fields_list); return 0; }
void print_fields(type_t type, void *object) { if (!object) { fatal ("Job or step record is NULL"); return; } slurmdb_job_rec_t *job = (slurmdb_job_rec_t *)object; slurmdb_step_rec_t *step = (slurmdb_step_rec_t *)object; jobcomp_job_rec_t *job_comp = (jobcomp_job_rec_t *)object; print_field_t *field = NULL; int curr_inx = 1; struct passwd *pw = NULL; struct group *gr = NULL; char outbuf[FORMAT_STRING_SIZE]; bool got_stats = false; int cpu_tres_rec_count = 0; int step_cpu_tres_rec_count = 0; switch(type) { case JOB: step = NULL; if (!job->track_steps) step = (slurmdb_step_rec_t *)job->first_step_ptr; /* set this to avoid printing out info for things that don't mean anything. Like an allocation that never ran anything. */ if (!step) job->track_steps = 1; else step_cpu_tres_rec_count = slurmdb_find_tres_count_in_string( step->tres_alloc_str, TRES_CPU); if (job->stats.cpu_min != NO_VAL) got_stats = true; job_comp = NULL; cpu_tres_rec_count = slurmdb_find_tres_count_in_string( (job->tres_alloc_str && job->tres_alloc_str[0]) ? job->tres_alloc_str : job->tres_req_str, TRES_CPU); break; case JOBSTEP: job = step->job_ptr; if (step->stats.cpu_min != NO_VAL) got_stats = true; if ((step_cpu_tres_rec_count = slurmdb_find_tres_count_in_string( step->tres_alloc_str, TRES_CPU)) == INFINITE64) step_cpu_tres_rec_count = slurmdb_find_tres_count_in_string( (job->tres_alloc_str && job->tres_alloc_str[0]) ? job->tres_alloc_str : job->tres_req_str, TRES_CPU); job_comp = NULL; break; case JOBCOMP: job = NULL; step = NULL; break; default: break; } if ((uint64_t)cpu_tres_rec_count == INFINITE64) cpu_tres_rec_count = 0; if ((uint64_t)step_cpu_tres_rec_count == INFINITE64) step_cpu_tres_rec_count = 0; list_iterator_reset(print_fields_itr); while((field = list_next(print_fields_itr))) { char *tmp_char = NULL, id[FORMAT_STRING_SIZE]; int tmp_int = NO_VAL, tmp_int2 = NO_VAL; double tmp_dub = (double)NO_VAL; /* don't use NO_VAL64 unless we can confirm the values coming in are NO_VAL64 */ uint32_t tmp_uint32 = NO_VAL; uint64_t tmp_uint64 = NO_VAL64; memset(&outbuf, 0, sizeof(outbuf)); switch(field->type) { case PRINT_ALLOC_CPUS: switch(type) { case JOB: tmp_int = cpu_tres_rec_count; // we want to use the step info if (!step) break; case JOBSTEP: tmp_int = step_cpu_tres_rec_count; break; case JOBCOMP: default: tmp_int = job_comp->proc_cnt; break; } field->print_routine(field, tmp_int, (curr_inx == field_count)); break; case PRINT_ALLOC_GRES: switch(type) { case JOB: tmp_char = job->alloc_gres; break; case JOBSTEP: tmp_char = step->job_ptr->alloc_gres; break; case JOBCOMP: default: tmp_char = NULL; break; } field->print_routine(field, tmp_char, (curr_inx == field_count)); break; case PRINT_ALLOC_NODES: switch(type) { case JOB: tmp_int = job->alloc_nodes; tmp_char = job->tres_alloc_str; break; case JOBSTEP: tmp_int = step->nnodes; tmp_char = step->tres_alloc_str; break; case JOBCOMP: tmp_int = job_comp->node_cnt; break; default: break; } if (!tmp_int && tmp_char) { if ((tmp_uint64 = slurmdb_find_tres_count_in_string( tmp_char, TRES_NODE)) != INFINITE64) tmp_int = tmp_uint64; } convert_num_unit((double)tmp_int, outbuf, sizeof(outbuf), UNIT_NONE, NO_VAL, params.convert_flags); field->print_routine(field, outbuf, (curr_inx == field_count)); break; case PRINT_ACCOUNT: switch(type) { case JOB: tmp_char = job->account; break; case JOBSTEP: tmp_char = step->job_ptr->account; break; case JOBCOMP: default: tmp_char = "n/a"; break; } field->print_routine(field, tmp_char, (curr_inx == field_count)); break; case PRINT_ACT_CPUFREQ: if (got_stats) { switch (type) { case JOB: if (!job->track_steps) tmp_dub = step->stats.act_cpufreq; break; case JOBSTEP: tmp_dub = step->stats.act_cpufreq; break; default: break; } } if (!fuzzy_equal(tmp_dub, NO_VAL)) convert_num_unit2((double)tmp_dub, outbuf, sizeof(outbuf), UNIT_KILO, params.units, 1000, params.convert_flags & (~CONVERT_NUM_UNIT_EXACT)); field->print_routine(field, outbuf, (curr_inx == field_count)); break; case PRINT_ASSOCID: switch(type) { case JOB: tmp_int = job->associd; break; case JOBSTEP: tmp_int = step->job_ptr->associd; break; case JOBCOMP: default: tmp_int = NO_VAL; break; } field->print_routine(field, tmp_int, (curr_inx == field_count)); break; case PRINT_AVECPU: if (got_stats) { switch(type) { case JOB: if (!job->track_steps) tmp_dub = job->stats.cpu_ave; break; case JOBSTEP: tmp_dub = step->stats.cpu_ave; break; case JOBCOMP: default: break; } } if (!fuzzy_equal(tmp_dub, NO_VAL)) tmp_char = _elapsed_time((long)tmp_dub, 0); field->print_routine(field, tmp_char, (curr_inx == field_count)); xfree(tmp_char); break; case PRINT_AVEDISKREAD: if (got_stats) { switch(type) { case JOB: if (!job->track_steps) tmp_dub = job-> stats.disk_read_ave; break; case JOBSTEP: tmp_dub = step->stats.disk_read_ave; break; case JOBCOMP: default: break; } } _print_small_double(outbuf, sizeof(outbuf), tmp_dub, UNIT_MEGA); field->print_routine(field, outbuf, (curr_inx == field_count)); break; case PRINT_AVEDISKWRITE: if (got_stats) { switch(type) { case JOB: if (!job->track_steps) tmp_dub = job-> stats.disk_write_ave; break; case JOBSTEP: tmp_dub = step->stats.disk_write_ave; break; case JOBCOMP: default: break; } } _print_small_double(outbuf, sizeof(outbuf), tmp_dub, UNIT_MEGA); field->print_routine(field, outbuf, (curr_inx == field_count)); break; case PRINT_AVEPAGES: if (got_stats) { switch(type) { case JOB: if (!job->track_steps) tmp_dub = job->stats.pages_ave; break; case JOBSTEP: tmp_dub = step->stats.pages_ave; break; case JOBCOMP: default: break; } } if (!fuzzy_equal(tmp_dub, NO_VAL)) convert_num_unit((double)tmp_dub, outbuf, sizeof(outbuf), UNIT_KILO, params.units, params.convert_flags); field->print_routine(field, outbuf, (curr_inx == field_count)); break; case PRINT_AVERSS: if (got_stats) { switch(type) { case JOB: if (!job->track_steps) tmp_dub = job->stats.rss_ave; break; case JOBSTEP: tmp_dub = step->stats.rss_ave; break; case JOBCOMP: default: break; } } if (!fuzzy_equal(tmp_dub, NO_VAL)) convert_num_unit((double)tmp_dub, outbuf, sizeof(outbuf), UNIT_KILO, params.units, params.convert_flags); field->print_routine(field, outbuf, (curr_inx == field_count)); break; case PRINT_AVEVSIZE: if (got_stats) { switch(type) { case JOB: if (!job->track_steps) tmp_dub = job->stats.vsize_ave; break; case JOBSTEP: tmp_dub = step->stats.vsize_ave; break; case JOBCOMP: default: break; } } if (!fuzzy_equal(tmp_dub, NO_VAL)) convert_num_unit((double)tmp_dub, outbuf, sizeof(outbuf), UNIT_KILO, params.units, params.convert_flags); field->print_routine(field, outbuf, (curr_inx == field_count)); break; case PRINT_BLOCKID: switch(type) { case JOB: tmp_char = job->blockid; break; case JOBSTEP: break; case JOBCOMP: tmp_char = job_comp->blockid; break; default: break; } field->print_routine(field, tmp_char, (curr_inx == field_count)); break; case PRINT_CLUSTER: switch(type) { case JOB: tmp_char = job->cluster; break; case JOBSTEP: tmp_char = step->job_ptr->cluster; break; case JOBCOMP: default: break; } field->print_routine(field, tmp_char, (curr_inx == field_count)); break; case PRINT_COMMENT: switch(type) { case JOB: tmp_char = job->derived_es; break; case JOBSTEP: case JOBCOMP: default: tmp_char = NULL; break; } field->print_routine(field, tmp_char, (curr_inx == field_count)); break; case PRINT_CONSUMED_ENERGY: if (got_stats) { switch (type) { case JOB: if (!job->track_steps) tmp_dub = step-> stats.consumed_energy; break; case JOBSTEP: tmp_dub = step->stats.consumed_energy; break; default: break; } } if (!fuzzy_equal(tmp_dub, NO_VAL)) convert_num_unit2((double)tmp_dub, outbuf, sizeof(outbuf), UNIT_NONE, params.units, 1000, params.convert_flags & (~CONVERT_NUM_UNIT_EXACT)); field->print_routine(field, outbuf, (curr_inx == field_count)); break; case PRINT_CONSUMED_ENERGY_RAW: if (got_stats) { switch (type) { case JOB: if (!job->track_steps) tmp_dub = step-> stats.consumed_energy; break; case JOBSTEP: tmp_dub = step->stats.consumed_energy; break; default: break; } } field->print_routine(field, tmp_dub, (curr_inx == field_count)); break; case PRINT_CPU_TIME: switch(type) { case JOB: tmp_uint64 = (uint64_t)job->elapsed * (uint64_t)cpu_tres_rec_count; break; case JOBSTEP: tmp_uint64 = (uint64_t)step->elapsed * (uint64_t)step_cpu_tres_rec_count; break; case JOBCOMP: break; default: break; } field->print_routine(field, tmp_uint64, (curr_inx == field_count)); break; case PRINT_CPU_TIME_RAW: switch(type) { case JOB: tmp_uint64 = (uint64_t)job->elapsed * (uint64_t)cpu_tres_rec_count; break; case JOBSTEP: tmp_uint64 = (uint64_t)step->elapsed * (uint64_t)step_cpu_tres_rec_count; break; case JOBCOMP: break; default: break; } field->print_routine(field, tmp_uint64, (curr_inx == field_count)); break; case PRINT_DERIVED_EC: tmp_int2 = 0; switch(type) { case JOB: tmp_int = job->derived_ec; if (tmp_int == NO_VAL) tmp_int = 0; if (WIFSIGNALED(tmp_int)) tmp_int2 = WTERMSIG(tmp_int); snprintf(outbuf, sizeof(outbuf), "%d:%d", WEXITSTATUS(tmp_int), tmp_int2); break; case JOBSTEP: case JOBCOMP: default: outbuf[0] = '\0'; break; } field->print_routine(field, outbuf, (curr_inx == field_count)); break; case PRINT_ELAPSED: switch(type) { case JOB: tmp_int = job->elapsed; break; case JOBSTEP: tmp_int = step->elapsed; break; case JOBCOMP: tmp_int = job_comp->elapsed_time; break; default: tmp_int = NO_VAL; break; } field->print_routine(field, (uint64_t)tmp_int, (curr_inx == field_count)); break; case PRINT_ELIGIBLE: switch(type) { case JOB: tmp_int = job->eligible; break; case JOBSTEP: tmp_int = step->start; break; case JOBCOMP: break; default: break; } field->print_routine(field, tmp_int, (curr_inx == field_count)); break; case PRINT_END: switch(type) { case JOB: tmp_int = job->end; break; case JOBSTEP: tmp_int = step->end; break; case JOBCOMP: tmp_int = parse_time(job_comp->end_time, 1); break; default: tmp_int = NO_VAL; break; } field->print_routine(field, tmp_int, (curr_inx == field_count)); break; case PRINT_EXITCODE: tmp_int = 0; tmp_int2 = 0; switch(type) { case JOB: tmp_int = job->exitcode; break; case JOBSTEP: tmp_int = step->exitcode; break; case JOBCOMP: default: break; } if (tmp_int != NO_VAL) { if (WIFSIGNALED(tmp_int)) tmp_int2 = WTERMSIG(tmp_int); tmp_int = WEXITSTATUS(tmp_int); if (tmp_int >= 128) tmp_int -= 128; } snprintf(outbuf, sizeof(outbuf), "%d:%d", tmp_int, tmp_int2); field->print_routine(field, outbuf, (curr_inx == field_count)); break; case PRINT_GID: switch(type) { case JOB: tmp_int = job->gid; break; case JOBSTEP: tmp_int = NO_VAL; break; case JOBCOMP: tmp_int = job_comp->gid; break; default: tmp_int = NO_VAL; break; } field->print_routine(field, tmp_int, (curr_inx == field_count)); break; case PRINT_GROUP: switch(type) { case JOB: tmp_int = job->gid; break; case JOBSTEP: tmp_int = NO_VAL; break; case JOBCOMP: tmp_int = job_comp->gid; break; default: tmp_int = NO_VAL; break; } tmp_char = NULL; if ((gr=getgrgid(tmp_int))) tmp_char=gr->gr_name; field->print_routine(field, tmp_char, (curr_inx == field_count)); break; case PRINT_JOBID: if (type == JOBSTEP) job = step->job_ptr; if (job) { if (job->array_task_str) { _xlate_task_str(job); snprintf(id, FORMAT_STRING_SIZE, "%u_[%s]", job->array_job_id, job->array_task_str); } else if (job->array_task_id != NO_VAL) snprintf(id, FORMAT_STRING_SIZE, "%u_%u", job->array_job_id, job->array_task_id); else snprintf(id, FORMAT_STRING_SIZE, "%u", job->jobid); } switch (type) { case JOB: tmp_char = xstrdup(id); break; case JOBSTEP: if (step->stepid == SLURM_BATCH_SCRIPT) { tmp_char = xstrdup_printf( "%s.batch", id); } else if (step->stepid == SLURM_EXTERN_CONT) { tmp_char = xstrdup_printf( "%s.extern", id); } else { tmp_char = xstrdup_printf( "%s.%u", id, step->stepid); } break; case JOBCOMP: tmp_char = xstrdup_printf("%u", job_comp->jobid); break; default: break; } field->print_routine(field, tmp_char, (curr_inx == field_count)); xfree(tmp_char); break; case PRINT_JOBIDRAW: switch (type) { case JOB: tmp_char = xstrdup_printf("%u", job->jobid); break; case JOBSTEP: if (step->stepid == SLURM_BATCH_SCRIPT) { tmp_char = xstrdup_printf( "%u.batch", step->job_ptr->jobid); } else if (step->stepid == SLURM_EXTERN_CONT) { tmp_char = xstrdup_printf( "%u.extern", step->job_ptr->jobid); } else { tmp_char = xstrdup_printf( "%u.%u", step->job_ptr->jobid, step->stepid); } break; case JOBCOMP: tmp_char = xstrdup_printf("%u", job_comp->jobid); break; default: break; } field->print_routine(field, tmp_char, (curr_inx == field_count)); xfree(tmp_char); break; case PRINT_JOBNAME: switch(type) { case JOB: tmp_char = job->jobname; break; case JOBSTEP: tmp_char = step->stepname; break; case JOBCOMP: tmp_char = job_comp->jobname; break; default: tmp_char = NULL; break; } field->print_routine(field, tmp_char, (curr_inx == field_count)); break; case PRINT_LAYOUT: switch(type) { case JOB: /* below really should be step. It is not a typo */ if (!job->track_steps) tmp_char = slurm_step_layout_type_name( step->task_dist); break; case JOBSTEP: tmp_char = slurm_step_layout_type_name( step->task_dist); break; case JOBCOMP: break; default: tmp_char = NULL; break; } field->print_routine(field, tmp_char, (curr_inx == field_count)); break; case PRINT_MAXDISKREAD: if (got_stats) { switch(type) { case JOB: if (!job->track_steps) tmp_dub = job-> stats.disk_read_max; break; case JOBSTEP: tmp_dub = step->stats.disk_read_max; break; case JOBCOMP: default: break; } } _print_small_double(outbuf, sizeof(outbuf), tmp_dub, UNIT_MEGA); field->print_routine(field, outbuf, (curr_inx == field_count)); break; case PRINT_MAXDISKREADNODE: if (got_stats) { switch(type) { case JOB: if (!job->track_steps) tmp_char = find_hostname( job->stats. disk_read_max_nodeid, job->nodes); break; case JOBSTEP: tmp_char = find_hostname( step->stats. disk_read_max_nodeid, step->nodes); break; case JOBCOMP: default: tmp_char = NULL; break; } } field->print_routine(field, tmp_char, (curr_inx == field_count)); xfree(tmp_char); break; case PRINT_MAXDISKREADTASK: if (got_stats) { switch(type) { case JOB: if (!job->track_steps) tmp_uint32 = job->stats. disk_read_max_taskid; break; case JOBSTEP: tmp_uint32 = step->stats. disk_read_max_taskid; break; case JOBCOMP: default: tmp_uint32 = NO_VAL; break; } } if (tmp_uint32 == (uint32_t)NO_VAL) tmp_uint32 = NO_VAL; field->print_routine(field, tmp_uint32, (curr_inx == field_count)); break; case PRINT_MAXDISKWRITE: if (got_stats) { switch(type) { case JOB: if (!job->track_steps) tmp_dub = job->stats. disk_write_max; break; case JOBSTEP: tmp_dub = step->stats.disk_write_max; break; case JOBCOMP: default: break; } } _print_small_double(outbuf, sizeof(outbuf), tmp_dub, UNIT_MEGA); field->print_routine(field, outbuf, (curr_inx == field_count)); break; case PRINT_MAXDISKWRITENODE: if (got_stats) { switch(type) { case JOB: if (!job->track_steps) tmp_char = find_hostname( job->stats. disk_write_max_nodeid, job->nodes); break; case JOBSTEP: tmp_char = find_hostname( step->stats. disk_write_max_nodeid, step->nodes); break; case JOBCOMP: default: tmp_char = NULL; break; } } field->print_routine(field, tmp_char, (curr_inx == field_count)); xfree(tmp_char); break; case PRINT_MAXDISKWRITETASK: if (got_stats) { switch(type) { case JOB: if (!job->track_steps) tmp_uint32 = job->stats. disk_write_max_taskid; break; case JOBSTEP: tmp_uint32 = step->stats. disk_write_max_taskid; break; case JOBCOMP: default: tmp_uint32 = NO_VAL; break; } if (tmp_uint32 == (uint32_t)NO_VAL) tmp_uint32 = NO_VAL; } field->print_routine(field, tmp_uint32, (curr_inx == field_count)); break; case PRINT_MAXPAGES: if (got_stats) { switch(type) { case JOB: if (!job->track_steps) tmp_uint64 = job->stats.pages_max; break; case JOBSTEP: tmp_uint64 = step->stats.pages_max; break; case JOBCOMP: default: break; } if (tmp_uint64 != (uint64_t)NO_VAL64) convert_num_unit( (double)tmp_uint64, outbuf, sizeof(outbuf), UNIT_KILO, params.units, params.convert_flags); } field->print_routine(field, outbuf, (curr_inx == field_count)); break; case PRINT_MAXPAGESNODE: if (got_stats) { switch(type) { case JOB: if (!job->track_steps) tmp_char = find_hostname( job->stats. pages_max_nodeid, job->nodes); break; case JOBSTEP: tmp_char = find_hostname( step->stats.pages_max_nodeid, step->nodes); break; case JOBCOMP: default: tmp_char = NULL; break; } } field->print_routine(field, tmp_char, (curr_inx == field_count)); xfree(tmp_char); break; case PRINT_MAXPAGESTASK: if (got_stats) { switch(type) { case JOB: if (!job->track_steps) tmp_uint32 = job->stats. pages_max_taskid; break; case JOBSTEP: tmp_uint32 = step->stats. pages_max_taskid; break; case JOBCOMP: default: tmp_uint32 = NO_VAL; break; } if (tmp_uint32 == (uint32_t)NO_VAL) tmp_uint32 = NO_VAL; } field->print_routine(field, tmp_uint32, (curr_inx == field_count)); break; case PRINT_MAXRSS: if (got_stats) { switch(type) { case JOB: if (!job->track_steps) tmp_uint64 = job->stats.rss_max; break; case JOBSTEP: tmp_uint64 = step->stats.rss_max; break; case JOBCOMP: default: break; } if (tmp_uint64 != (uint64_t)NO_VAL64) convert_num_unit( (double)tmp_uint64, outbuf, sizeof(outbuf), UNIT_KILO, params.units, params.convert_flags); } field->print_routine(field, outbuf, (curr_inx == field_count)); break; case PRINT_MAXRSSNODE: if (got_stats) { switch(type) { case JOB: if (!job->track_steps) tmp_char = find_hostname( job->stats. rss_max_nodeid, job->nodes); break; case JOBSTEP: tmp_char = find_hostname( step->stats.rss_max_nodeid, step->nodes); break; case JOBCOMP: default: tmp_char = NULL; break; } } field->print_routine(field, tmp_char, (curr_inx == field_count)); xfree(tmp_char); break; case PRINT_MAXRSSTASK: if (got_stats) { switch(type) { case JOB: if (!job->track_steps) tmp_uint32 = job->stats. rss_max_taskid; break; case JOBSTEP: tmp_uint32 = step->stats.rss_max_taskid; break; case JOBCOMP: default: tmp_uint32 = NO_VAL; break; } if (tmp_uint32 == (uint32_t)NO_VAL) tmp_uint32 = NO_VAL; } field->print_routine(field, tmp_uint32, (curr_inx == field_count)); break; case PRINT_MAXVSIZE: if (got_stats) { switch(type) { case JOB: if (!job->track_steps) tmp_uint64 = job->stats. vsize_max; break; case JOBSTEP: tmp_uint64 = step->stats.vsize_max; break; case JOBCOMP: default: tmp_uint64 = (uint64_t)NO_VAL64; break; } if (tmp_uint64 != (uint64_t)NO_VAL64) convert_num_unit( (double)tmp_uint64, outbuf, sizeof(outbuf), UNIT_KILO, params.units, params.convert_flags); } field->print_routine(field, outbuf, (curr_inx == field_count)); break; case PRINT_MAXVSIZENODE: if (got_stats) { switch(type) { case JOB: if (!job->track_steps) tmp_char = find_hostname( job->stats. vsize_max_nodeid, job->nodes); break; case JOBSTEP: tmp_char = find_hostname( step->stats.vsize_max_nodeid, step->nodes); break; case JOBCOMP: default: tmp_char = NULL; break; } } field->print_routine(field, tmp_char, (curr_inx == field_count)); xfree(tmp_char); break; case PRINT_MAXVSIZETASK: if (got_stats) { switch(type) { case JOB: if (!job->track_steps) tmp_uint32 = job->stats. vsize_max_taskid; break; case JOBSTEP: tmp_uint32 = step->stats. vsize_max_taskid; break; case JOBCOMP: default: tmp_uint32 = NO_VAL; break; } if (tmp_uint32 == (uint32_t)NO_VAL) tmp_uint32 = NO_VAL; } field->print_routine(field, tmp_uint32, (curr_inx == field_count)); break; case PRINT_MINCPU: if (got_stats) { switch(type) { case JOB: if (!job->track_steps) tmp_dub = job->stats.cpu_min; break; case JOBSTEP: tmp_dub = step->stats.cpu_min; break; case JOBCOMP: default: break; } if (!fuzzy_equal(tmp_dub, NO_VAL)) tmp_char = _elapsed_time( (long)tmp_dub, 0); } field->print_routine(field, tmp_char, (curr_inx == field_count)); xfree(tmp_char); break; case PRINT_MINCPUNODE: if (got_stats) { switch(type) { case JOB: if (!job->track_steps) tmp_char = find_hostname( job->stats. cpu_min_nodeid, job->nodes); break; case JOBSTEP: tmp_char = find_hostname( step->stats.cpu_min_nodeid, step->nodes); break; case JOBCOMP: default: tmp_char = NULL; break; } } field->print_routine(field, tmp_char, (curr_inx == field_count)); xfree(tmp_char); break; case PRINT_MINCPUTASK: if (got_stats) { switch(type) { case JOB: if (!job->track_steps) tmp_uint32 = job->stats. cpu_min_taskid; break; case JOBSTEP: tmp_uint32 = step->stats.cpu_min_taskid; break; case JOBCOMP: default: tmp_uint32 = NO_VAL; break; } if (tmp_uint32 == (uint32_t)NO_VAL) tmp_uint32 = NO_VAL; } field->print_routine(field, tmp_uint32, (curr_inx == field_count)); break; case PRINT_NODELIST: switch(type) { case JOB: tmp_char = job->nodes; break; case JOBSTEP: tmp_char = step->nodes; break; case JOBCOMP: tmp_char = job_comp->nodelist; break; default: break; } field->print_routine(field, tmp_char, (curr_inx == field_count)); break; case PRINT_NNODES: switch(type) { case JOB: tmp_int = job->alloc_nodes; tmp_char = (job->tres_alloc_str && job->tres_alloc_str[0]) ? job->tres_alloc_str : job->tres_req_str; break; case JOBSTEP: tmp_int = step->nnodes; tmp_char = step->tres_alloc_str; break; case JOBCOMP: tmp_int = job_comp->node_cnt; break; default: break; } if (!tmp_int && tmp_char) { if ((tmp_uint64 = slurmdb_find_tres_count_in_string( tmp_char, TRES_NODE)) != INFINITE64) tmp_int = tmp_uint64; } convert_num_unit((double)tmp_int, outbuf, sizeof(outbuf), UNIT_NONE, params.units, params.convert_flags); field->print_routine(field, outbuf, (curr_inx == field_count)); break; case PRINT_NTASKS: switch(type) { case JOB: if (!job->track_steps && !step) tmp_int = cpu_tres_rec_count; // we want to use the step info if (!step) break; case JOBSTEP: tmp_int = step->ntasks; break; case JOBCOMP: default: break; } field->print_routine(field, tmp_int, (curr_inx == field_count)); break; case PRINT_PRIO: switch(type) { case JOB: tmp_int = job->priority; break; case JOBSTEP: break; case JOBCOMP: break; default: break; } field->print_routine(field, tmp_int, (curr_inx == field_count)); break; case PRINT_PARTITION: switch(type) { case JOB: tmp_char = job->partition; break; case JOBSTEP: break; case JOBCOMP: tmp_char = job_comp->partition; break; default: break; } field->print_routine(field, tmp_char, (curr_inx == field_count)); break; case PRINT_QOS: switch(type) { case JOB: tmp_int = job->qosid; break; case JOBSTEP: break; case JOBCOMP: break; default: break; } if (!g_qos_list) { slurmdb_qos_cond_t qos_cond; memset(&qos_cond, 0, sizeof(slurmdb_qos_cond_t)); qos_cond.with_deleted = 1; g_qos_list = slurmdb_qos_get( acct_db_conn, &qos_cond); } tmp_char = _find_qos_name_from_list(g_qos_list, tmp_int); field->print_routine(field, tmp_char, (curr_inx == field_count)); break; case PRINT_QOSRAW: switch(type) { case JOB: tmp_int = job->qosid; break; case JOBSTEP: break; case JOBCOMP: break; default: break; } field->print_routine(field, tmp_int, (curr_inx == field_count)); break; case PRINT_REQ_CPUFREQ_MIN: switch (type) { case JOB: if (!job->track_steps && !step) tmp_dub = NO_VAL; // we want to use the step info if (!step) break; case JOBSTEP: tmp_dub = step->req_cpufreq_min; break; default: break; } cpu_freq_to_string(outbuf, sizeof(outbuf), tmp_dub); field->print_routine(field, outbuf, (curr_inx == field_count)); break; case PRINT_REQ_CPUFREQ_MAX: switch (type) { case JOB: if (!job->track_steps && !step) tmp_dub = NO_VAL; // we want to use the step info if (!step) break; case JOBSTEP: tmp_dub = step->req_cpufreq_max; break; default: break; } cpu_freq_to_string(outbuf, sizeof(outbuf), tmp_dub); field->print_routine(field, outbuf, (curr_inx == field_count)); break; case PRINT_REQ_CPUFREQ_GOV: switch (type) { case JOB: if (!job->track_steps && !step) tmp_dub = NO_VAL; // we want to use the step info if (!step) break; case JOBSTEP: tmp_dub = step->req_cpufreq_gov; break; default: break; } cpu_freq_to_string(outbuf, sizeof(outbuf), tmp_dub); field->print_routine(field, outbuf, (curr_inx == field_count)); break; case PRINT_REQ_CPUS: switch(type) { case JOB: tmp_int = job->req_cpus; break; case JOBSTEP: tmp_int = step_cpu_tres_rec_count; break; case JOBCOMP: break; default: break; } field->print_routine(field, tmp_int, (curr_inx == field_count)); break; case PRINT_REQ_GRES: switch(type) { case JOB: tmp_char = job->req_gres; break; case JOBSTEP: tmp_char = step->job_ptr->req_gres; break; case JOBCOMP: default: tmp_char = NULL; break; } field->print_routine(field, tmp_char, (curr_inx == field_count)); break; case PRINT_REQ_MEM: switch(type) { case JOB: tmp_uint32 = job->req_mem; break; case JOBSTEP: tmp_uint32 = step->job_ptr->req_mem; break; case JOBCOMP: default: tmp_uint32 = NO_VAL; break; } if (tmp_uint32 != (uint32_t)NO_VAL) { bool per_cpu = false; if (tmp_uint32 & MEM_PER_CPU) { tmp_uint32 &= (~MEM_PER_CPU); per_cpu = true; } convert_num_unit((double)tmp_uint32, outbuf, sizeof(outbuf), UNIT_MEGA, params.units, params.convert_flags); if (per_cpu) sprintf(outbuf+strlen(outbuf), "c"); else sprintf(outbuf+strlen(outbuf), "n"); } field->print_routine(field, outbuf, (curr_inx == field_count)); break; case PRINT_REQ_NODES: switch(type) { case JOB: tmp_int = 0; tmp_char = job->tres_req_str; break; case JOBSTEP: tmp_int = step->nnodes; tmp_char = step->tres_alloc_str; break; case JOBCOMP: tmp_int = job_comp->node_cnt; break; default: break; } if (!tmp_int && tmp_char) { if ((tmp_uint64 = slurmdb_find_tres_count_in_string( tmp_char, TRES_NODE)) != INFINITE64) tmp_int = tmp_uint64; } convert_num_unit((double)tmp_int, outbuf, sizeof(outbuf), UNIT_NONE, params.units, params.convert_flags); field->print_routine(field, outbuf, (curr_inx == field_count)); break; case PRINT_RESERVATION: switch(type) { case JOB: if (job->resv_name) { tmp_char = job->resv_name; } else { tmp_char = NULL; } break; case JOBSTEP: tmp_char = NULL; break; case JOBCOMP: tmp_char = NULL; break; default: tmp_char = NULL; break; } field->print_routine(field, tmp_char, (curr_inx == field_count)); break; case PRINT_RESERVATION_ID: switch(type) { case JOB: if (job->resvid) tmp_uint32 = job->resvid; else tmp_uint32 = NO_VAL; break; case JOBSTEP: tmp_uint32 = NO_VAL; break; case JOBCOMP: tmp_uint32 = NO_VAL; break; default: tmp_uint32 = NO_VAL; break; } if (tmp_uint32 == (uint32_t)NO_VAL) tmp_uint32 = NO_VAL; field->print_routine(field, tmp_uint32, (curr_inx == field_count)); break; case PRINT_RESV: switch(type) { case JOB: if (job->start) tmp_int = job->start - job->eligible; else tmp_int = time(NULL) - job->eligible; break; case JOBSTEP: break; case JOBCOMP: break; default: break; } field->print_routine(field, (uint64_t)tmp_int, (curr_inx == field_count)); break; case PRINT_RESV_CPU: switch(type) { case JOB: if (job->start) tmp_int = (job->start - job->eligible) * job->req_cpus; else tmp_int = (time(NULL) - job->eligible) * job->req_cpus; break; case JOBSTEP: break; case JOBCOMP: break; default: break; } field->print_routine(field, (uint64_t)tmp_int, (curr_inx == field_count)); break; case PRINT_RESV_CPU_RAW: switch(type) { case JOB: if (job->start) tmp_int = (job->start - job->eligible) * job->req_cpus; else tmp_int = (time(NULL) - job->eligible) * job->req_cpus; break; case JOBSTEP: break; case JOBCOMP: break; default: break; } field->print_routine(field, tmp_int, (curr_inx == field_count)); break; case PRINT_START: switch(type) { case JOB: tmp_int = job->start; break; case JOBSTEP: tmp_int = step->start; break; case JOBCOMP: tmp_int = parse_time(job_comp->start_time, 1); break; default: break; } field->print_routine(field, tmp_int, (curr_inx == field_count)); break; case PRINT_STATE: switch(type) { case JOB: tmp_int = job->state; tmp_int2 = job->requid; break; case JOBSTEP: tmp_int = step->state; tmp_int2 = step->requid; break; case JOBCOMP: tmp_char = job_comp->state; break; default: break; } if (((tmp_int & JOB_STATE_BASE) == JOB_CANCELLED) && (tmp_int2 != -1)) snprintf(outbuf, FORMAT_STRING_SIZE, "%s by %d", job_state_string(tmp_int), tmp_int2); else if (tmp_int != NO_VAL) snprintf(outbuf, FORMAT_STRING_SIZE, "%s", job_state_string(tmp_int)); else if (tmp_char) snprintf(outbuf, FORMAT_STRING_SIZE, "%s", tmp_char); field->print_routine(field, outbuf, (curr_inx == field_count)); break; case PRINT_SUBMIT: switch(type) { case JOB: tmp_int = job->submit; break; case JOBSTEP: tmp_int = step->start; break; case JOBCOMP: tmp_int = parse_time(job_comp->start_time, 1); break; default: break; } field->print_routine(field, tmp_int, (curr_inx == field_count)); break; case PRINT_SUSPENDED: switch(type) { case JOB: tmp_int = job->suspended; break; case JOBSTEP: tmp_int = step->suspended; break; case JOBCOMP: break; default: break; } field->print_routine(field, (uint64_t)tmp_int, (curr_inx == field_count)); break; case PRINT_SYSTEMCPU: if (got_stats) { switch(type) { case JOB: tmp_int = job->sys_cpu_sec; tmp_int2 = job->sys_cpu_usec; break; case JOBSTEP: tmp_int = step->sys_cpu_sec; tmp_int2 = step->sys_cpu_usec; break; case JOBCOMP: default: break; } tmp_char = _elapsed_time(tmp_int, tmp_int2); } field->print_routine(field, tmp_char, (curr_inx == field_count)); xfree(tmp_char); break; case PRINT_TIMELIMIT: switch(type) { case JOB: if (job->timelimit == INFINITE) tmp_char = "UNLIMITED"; else if (job->timelimit == NO_VAL) tmp_char = "Partition_Limit"; else if (job->timelimit) { char tmp1[128]; mins2time_str(job->timelimit, tmp1, sizeof(tmp1)); tmp_char = tmp1; } break; case JOBSTEP: break; case JOBCOMP: tmp_char = job_comp->timelimit; break; default: break; } field->print_routine(field, tmp_char, (curr_inx == field_count)); break; case PRINT_TOTALCPU: switch(type) { case JOB: tmp_int = job->tot_cpu_sec; tmp_int2 = job->tot_cpu_usec; break; case JOBSTEP: tmp_int = step->tot_cpu_sec; tmp_int2 = step->tot_cpu_usec; break; case JOBCOMP: break; default: break; } tmp_char = _elapsed_time(tmp_int, tmp_int2); field->print_routine(field, tmp_char, (curr_inx == field_count)); xfree(tmp_char); break; case PRINT_TRESA: switch(type) { case JOB: tmp_char = job->tres_alloc_str; break; case JOBSTEP: tmp_char = step->tres_alloc_str; break; case JOBCOMP: default: tmp_char = NULL; break; } if (!g_tres_list) { slurmdb_tres_cond_t tres_cond; memset(&tres_cond, 0, sizeof(slurmdb_tres_cond_t)); tres_cond.with_deleted = 1; g_tres_list = slurmdb_tres_get( acct_db_conn, &tres_cond); } tmp_char = slurmdb_make_tres_string_from_simple( tmp_char, g_tres_list, params.units, params.convert_flags); field->print_routine(field, tmp_char, (curr_inx == field_count)); xfree(tmp_char); break; case PRINT_TRESR: switch(type) { case JOB: tmp_char = job->tres_req_str; break; case JOBSTEP: case JOBCOMP: default: tmp_char = NULL; break; } if (!g_tres_list) { slurmdb_tres_cond_t tres_cond; memset(&tres_cond, 0, sizeof(slurmdb_tres_cond_t)); tres_cond.with_deleted = 1; g_tres_list = slurmdb_tres_get( acct_db_conn, &tres_cond); } tmp_char = slurmdb_make_tres_string_from_simple( tmp_char, g_tres_list, params.units, params.convert_flags); field->print_routine(field, tmp_char, (curr_inx == field_count)); xfree(tmp_char); break; case PRINT_UID: switch(type) { case JOB: if (job->user) { if ((pw=getpwnam(job->user))) tmp_int = pw->pw_uid; } else tmp_int = job->uid; break; case JOBSTEP: break; case JOBCOMP: tmp_int = job_comp->uid; break; default: break; } field->print_routine(field, tmp_int, (curr_inx == field_count)); break; case PRINT_USER: switch(type) { case JOB: if (job->user) tmp_char = job->user; else if (job->uid != -1) { if ((pw=getpwuid(job->uid))) tmp_char = pw->pw_name; } break; case JOBSTEP: break; case JOBCOMP: tmp_char = job_comp->uid_name; break; default: break; } field->print_routine(field, tmp_char, (curr_inx == field_count)); break; case PRINT_USERCPU: if (got_stats) { switch(type) { case JOB: tmp_int = job->user_cpu_sec; tmp_int2 = job->user_cpu_usec; break; case JOBSTEP: tmp_int = step->user_cpu_sec; tmp_int2 = step->user_cpu_usec; break; case JOBCOMP: default: break; } tmp_char = _elapsed_time(tmp_int, tmp_int2); } field->print_routine(field, tmp_char, (curr_inx == field_count)); xfree(tmp_char); break; case PRINT_WCKEY: switch(type) { case JOB: tmp_char = job->wckey; break; case JOBSTEP: break; case JOBCOMP: break; default: break; } field->print_routine(field, tmp_char, (curr_inx == field_count)); break; case PRINT_WCKEYID: switch(type) { case JOB: tmp_int = job->wckeyid; break; case JOBSTEP: break; case JOBCOMP: break; default: break; } field->print_routine(field, tmp_int, (curr_inx == field_count)); break; default: break; } curr_inx++; } printf("\n"); }