/* * scontrol_print_job - print the specified job's information * IN job_id - job's id or NULL to print information about all jobs */ extern void scontrol_print_job (char * job_id_str) { int error_code = SLURM_SUCCESS, i, print_cnt = 0; uint32_t job_id = 0; uint16_t array_id = (uint16_t) NO_VAL; job_info_msg_t * job_buffer_ptr = NULL; job_info_t *job_ptr = NULL; char *end_ptr = NULL; if (job_id_str) { job_id = (uint32_t) strtol (job_id_str, &end_ptr, 10); if (end_ptr[0] == '_') array_id = strtol( end_ptr + 1, &end_ptr, 10 ); } error_code = scontrol_load_job(&job_buffer_ptr, job_id); if (error_code) { exit_code = 1; if (quiet_flag != 1) slurm_perror ("slurm_load_jobs error"); return; } if (quiet_flag == -1) { char time_str[32]; slurm_make_time_str ((time_t *)&job_buffer_ptr->last_update, time_str, sizeof(time_str)); printf ("last_update_time=%s, records=%d\n", time_str, job_buffer_ptr->record_count); } job_ptr = job_buffer_ptr->job_array ; for (i = 0, job_ptr = job_buffer_ptr->job_array; i < job_buffer_ptr->record_count; i++, job_ptr++) { if ((array_id != (uint16_t) NO_VAL) && (array_id != job_ptr->array_task_id)) continue; slurm_print_job_info(stdout, job_ptr, one_liner); print_cnt++; } if (print_cnt == 0) { if (job_id_str) { exit_code = 1; if (quiet_flag != 1) { if (array_id == (uint16_t) NO_VAL) { printf("Job %u not found\n", job_id); } else { printf("Job %u_%u not found\n", job_id, array_id); } } } else if (quiet_flag != 1) printf ("No jobs in the system\n"); } }
/* * slurm_print_job_info_msg - output information about all Slurm * jobs based upon message as loaded using slurm_load_jobs * IN out - file to write to * IN job_info_msg_ptr - job information message pointer * IN one_liner - print as a single line if true */ extern void slurm_print_job_info_msg ( FILE* out, job_info_msg_t *jinfo, int one_liner ) { int i; job_info_t *job_ptr = jinfo->job_array; char time_str[32]; slurm_make_time_str ((time_t *)&jinfo->last_update, time_str, sizeof(time_str)); fprintf( out, "Job data as of %s, record count %d\n", time_str, jinfo->record_count); for (i = 0; i < jinfo->record_count; i++) slurm_print_job_info(out, &job_ptr[i], one_liner); }
/* * scontrol_print_job - print the specified job's information * IN job_id - job's id or NULL to print information about all jobs */ extern void scontrol_print_job(char * job_id_str) { int error_code = SLURM_SUCCESS, i, print_cnt = 0; uint32_t job_id = 0; uint32_t array_id = NO_VAL, pack_job_offset = NO_VAL; job_info_msg_t * job_buffer_ptr = NULL; job_info_t *job_ptr = NULL; char *end_ptr = NULL; if (job_id_str) { char *tmp_job_ptr = job_id_str; /* * Check that the input is a valid job id (i.e. 123 or 123_456). */ while (*tmp_job_ptr) { if (!isdigit(*tmp_job_ptr) && (*tmp_job_ptr != '_') && (*tmp_job_ptr != '+')) { exit_code = 1; slurm_seterrno(ESLURM_INVALID_JOB_ID); if (quiet_flag != 1) slurm_perror("scontrol_print_job error"); return; } ++tmp_job_ptr; } job_id = (uint32_t) strtol (job_id_str, &end_ptr, 10); if (end_ptr[0] == '_') array_id = strtol(end_ptr + 1, &end_ptr, 10); if (end_ptr[0] == '+') pack_job_offset = strtol(end_ptr + 1, &end_ptr, 10); } error_code = scontrol_load_job(&job_buffer_ptr, job_id); if (error_code) { exit_code = 1; if (quiet_flag != 1) slurm_perror ("slurm_load_jobs error"); return; } if (quiet_flag == -1) { char time_str[32]; slurm_make_time_str ((time_t *)&job_buffer_ptr->last_update, time_str, sizeof(time_str)); printf ("last_update_time=%s, records=%d\n", time_str, job_buffer_ptr->record_count); } for (i = 0, job_ptr = job_buffer_ptr->job_array; i < job_buffer_ptr->record_count; i++, job_ptr++) { char *save_array_str = NULL; uint32_t save_task_id = 0; if (!_pack_id_match(job_ptr, pack_job_offset)) continue; if (!_task_id_in_job(job_ptr, array_id)) continue; if ((array_id != NO_VAL) && job_ptr->array_task_str) { save_array_str = job_ptr->array_task_str; job_ptr->array_task_str = NULL; save_task_id = job_ptr->array_task_id; job_ptr->array_task_id = array_id; } slurm_print_job_info(stdout, job_ptr, one_liner); if (save_array_str) { job_ptr->array_task_str = save_array_str; job_ptr->array_task_id = save_task_id; } print_cnt++; } if (print_cnt == 0) { if (job_id_str) { exit_code = 1; if (quiet_flag != 1) { if (array_id != NO_VAL) { printf("Job %u_%u not found\n", job_id, array_id); } else if (pack_job_offset != NO_VAL) { printf("Job %u+%u not found\n", job_id, pack_job_offset); } else { printf("Job %u not found\n", job_id); } } } else if (quiet_flag != 1) printf ("No jobs in the system\n"); } }