diff --git a/src/api/config_info.c b/src/api/config_info.c index 1d02749b9bb3e3c9e84e4c5cfbd965ed24f30fa4..dd4ddb908ab294327d0712dd9e2f0cc2080aa590 100644 --- a/src/api/config_info.c +++ b/src/api/config_info.c @@ -35,10 +35,13 @@ /* slurm_print_ctl_conf - output the contents of Slurm's configuration message */ void slurm_print_ctl_conf ( FILE* out, slurm_ctl_conf_info_msg_t * slurm_ctl_conf_ptr ) { + char time_str[16]; + if ( slurm_ctl_conf_ptr == NULL ) return ; - fprintf(out, "Configuration updated at %ld\n", (time_t)slurm_ctl_conf_ptr->last_update); + make_time_str ((time_t *)&slurm_ctl_conf_ptr->last_update, time_str); + fprintf(out, "Configuration updated at %s\n", time_str); fprintf(out, "BackupController = %s\n", slurm_ctl_conf_ptr->backup_controller); fprintf(out, "ControlMachine = %s\n", slurm_ctl_conf_ptr->control_machine); fprintf(out, "Epilog = %s\n", slurm_ctl_conf_ptr->epilog); diff --git a/src/api/job_info.c b/src/api/job_info.c index 985c4dfcf6129ec1681d163f4b1141ac86445187..9eb6c1f7a342755354b74c5c5892058f7e33f74c 100644 --- a/src/api/job_info.c +++ b/src/api/job_info.c @@ -31,6 +31,7 @@ #include <errno.h> #include <stdio.h> #include <stdlib.h> +#include <time.h> #include <src/api/slurm.h> #include <src/common/slurm_protocol_api.h> @@ -41,9 +42,11 @@ slurm_print_job_info_msg ( FILE* out, job_info_msg_t * job_info_msg_ptr ) { int i; job_info_t * job_ptr = job_info_msg_ptr -> job_array ; + char time_str[16]; - fprintf( out, "Jobs updated at %ld, record count %d\n", - (long) job_info_msg_ptr ->last_update, job_info_msg_ptr->record_count); + make_time_str ((time_t *)&job_info_msg_ptr->last_update, time_str); + fprintf( out, "Jobs updated at %s, record count %d\n", + time_str, job_info_msg_ptr->record_count); for (i = 0; i < job_info_msg_ptr-> record_count; i++) { @@ -56,12 +59,16 @@ void slurm_print_job_info ( FILE* out, job_info_t * job_ptr ) { int j; + char time_str[16]; fprintf ( out, "JobId=%u UserId=%u Name=%s ", job_ptr->job_id, job_ptr->user_id, job_ptr->name); fprintf ( out, "JobState=%s TimeLimit=%u ", job_state_string(job_ptr->job_state), job_ptr->time_limit); fprintf ( out, "Priority=%u Partition=%s\n", job_ptr->priority, job_ptr->partition); - fprintf ( out, " StartTime=%u EndTime=%u ", (uint32_t) job_ptr->start_time, (uint32_t) job_ptr->end_time); + make_time_str ((time_t *)&job_ptr->start_time, time_str); + fprintf ( out, " StartTime=%s ", time_str); + make_time_str ((time_t *)&job_ptr->end_time, time_str); + fprintf ( out, "EndTime=%s ", time_str); fprintf ( out, "NodeList=%s ", job_ptr->nodes); fprintf ( out, "NodeListIndecies="); @@ -92,6 +99,18 @@ slurm_print_job_info ( FILE* out, job_info_t * job_ptr ) fprintf( out, "\n\n"); } +/* make_time_str - convert time_t to string with "month/date hour:min:sec" */ +void +make_time_str (time_t *time, char *string) +{ + struct tm time_tm; + + localtime_r (time, &time_tm); + sprintf ( string, "%d/%d,%d:%2.2d:%2.2d", (time_tm.tm_mon+1), time_tm.tm_mday, + time_tm.tm_hour, time_tm.tm_min, time_tm.tm_sec); +} + + /* slurm_load_jobs - issue RPC to get Slurm job state information if changed since update_time */ int slurm_load_jobs (time_t update_time, job_info_msg_t **job_info_msg_pptr) diff --git a/src/api/job_step_info.c b/src/api/job_step_info.c index 0426ee29e82bc9d8185b137431009fa8b58e1a94..f1023e698f1d3a33019a7d5b8f36641297b1294e 100644 --- a/src/api/job_step_info.c +++ b/src/api/job_step_info.c @@ -41,9 +41,11 @@ slurm_print_job_step_info_msg ( FILE* out, job_step_info_response_msg_t * job_st { int i; job_step_info_t * job_step_ptr = job_step_info_msg_ptr -> job_steps ; + char time_str[16]; - fprintf( out, "Job steps updated at %ld, record count %d\n", - (long) job_step_info_msg_ptr ->last_update, job_step_info_msg_ptr->job_step_count); + make_time_str ((time_t *)&job_step_info_msg_ptr->last_update, time_str); + fprintf( out, "Job steps updated at %s, record count %d\n", + time_str, job_step_info_msg_ptr->job_step_count); for (i = 0; i < job_step_info_msg_ptr-> job_step_count; i++) { diff --git a/src/api/node_info.c b/src/api/node_info.c index 08c0734c19bf64d6b4f8761620428f4a4e700b54..663400a525ccfd6e074856aa7d7bd7c90c2504cb 100644 --- a/src/api/node_info.c +++ b/src/api/node_info.c @@ -47,9 +47,11 @@ slurm_print_node_info_msg ( FILE* out, node_info_msg_t * node_info_msg_ptr ) { int i; node_info_t * node_ptr = node_info_msg_ptr -> node_array ; + char time_str[16]; - fprintf( out, "Nodes updated at %d, record count %d\n", - node_info_msg_ptr ->last_update, node_info_msg_ptr->record_count); + make_time_str ((time_t *)&node_info_msg_ptr->last_update, time_str); + fprintf( out, "Nodes updated at %s, record count %d\n", + time_str, node_info_msg_ptr->record_count); for (i = 0; i < node_info_msg_ptr-> record_count; i++) { diff --git a/src/api/partition_info.c b/src/api/partition_info.c index b968f8da1978a483833297afedceaf8271e06c29..530b0eee9e9e85a27fd80a8a74e6f1f256990f59 100644 --- a/src/api/partition_info.c +++ b/src/api/partition_info.c @@ -41,9 +41,11 @@ void slurm_print_partition_info_msg ( FILE* out, partition_info_msg_t * part_inf { int i ; partition_info_t * part_ptr = part_info_ptr->partition_array ; + char time_str[16]; - fprintf( out, "Partitions updated at %ld, record count %d\n", - (long) part_info_ptr ->last_update, part_info_ptr->record_count); + make_time_str ((time_t *)&part_info_ptr->last_update, time_str); + fprintf( out, "Partitions updated at %s, record count %d\n", + time_str, part_info_ptr->record_count); for (i = 0; i < part_info_ptr->record_count; i++) { slurm_print_partition_info ( out, & part_ptr[i] ) ; diff --git a/src/api/slurm.h b/src/api/slurm.h index 884cef695ca6db9dcf089d040d9bb4bba43ab382..98edf070d73f7ced1e8c0d38bcbe34ddb874844d 100644 --- a/src/api/slurm.h +++ b/src/api/slurm.h @@ -30,6 +30,9 @@ #include <src/common/slurm_protocol_defs.h> #include <stdio.h> +/* make_time_str - convert time_t to string with "month/date hour:min:sec" */ +extern void make_time_str (time_t *time, char *string); + /* * slurm_allocate - allocate nodes for a job with supplied contraints. * NOTE: the calling function must free the allocated storage at node_list[0] diff --git a/src/scontrol/scontrol.c b/src/scontrol/scontrol.c index 5f048d797e3d2a6bd4b98a620ea534ae0931c590..153d3a56ae1e787d556f8d8a6f576b013a50e9a4 100644 --- a/src/scontrol/scontrol.c +++ b/src/scontrol/scontrol.c @@ -79,7 +79,7 @@ void usage (); int main (int argc, char *argv[]) { - int error_code, i, input_field_count; + int error_code = 0, i, input_field_count; char **input_fields; log_options_t opts = LOG_OPTS_STDERR_ONLY ; @@ -249,8 +249,12 @@ print_job (char * job_id_str) } old_job_buffer_ptr = job_buffer_ptr; - if (quiet_flag == -1) - printf ("last_update_time=%ld\n", (long) job_buffer_ptr->last_update); + if (quiet_flag == -1) { + char time_str[16]; + make_time_str ((time_t *)&job_buffer_ptr->last_update, time_str); + printf ("last_update_time=%s, records=%d\n", + time_str, job_buffer_ptr->record_count); + } if (job_id_str) job_id = (uint32_t) strtol (job_id_str, (char **)NULL, 10); @@ -349,9 +353,12 @@ print_node_list (char *node_list) old_node_info_ptr = node_info_ptr; - if (quiet_flag == -1) - printf ("last_update_time=%ld, records=%d\n", - (long) node_info_ptr->last_update, node_info_ptr->record_count); + if (quiet_flag == -1) { + char time_str[16]; + make_time_str ((time_t *)&node_info_ptr->last_update, time_str); + printf ("last_update_time=%s, records=%d\n", + time_str, node_info_ptr->record_count); + } if (node_list == NULL) { print_node (NULL, node_info_ptr); @@ -412,8 +419,12 @@ print_part (char *partition_name) old_part_info_ptr = part_info_ptr; - if (quiet_flag == -1) - printf ("last_update_time=%ld\n", (long) part_info_ptr->last_update); + if (quiet_flag == -1) { + char time_str[16]; + make_time_str ((time_t *)&part_info_ptr->last_update, time_str); + printf ("last_update_time=%s, records=%d\n", + time_str, part_info_ptr->record_count); + } part_ptr = part_info_ptr->partition_array; for (i = 0; i < part_info_ptr->record_count; i++) { @@ -486,8 +497,12 @@ print_step (char *job_step_id_str) last_job_id = job_id; last_step_id = step_id; - if (quiet_flag == -1) - printf ("last_update_time=%ld\n", (long) job_step_info_ptr->last_update); + if (quiet_flag == -1) { + char time_str[16]; + make_time_str ((time_t *)&job_step_info_ptr->last_update, time_str); + printf ("last_update_time=%s, records=%d\n", + time_str, job_step_info_ptr->job_step_count); + } job_step_ptr = job_step_info_ptr->job_steps ; for (i = 0; i < job_step_info_ptr->job_step_count; i++) {