/* * 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; 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); } 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 (!_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 == (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"); } }
/* * 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"); } }