Skip to content
Snippets Groups Projects
Commit 102b1bff authored by Moe Jette's avatar Moe Jette
Browse files

Convert time-stamp printing form %ld format to "month/date,hour:min:sec" string.

parent dea92e9a
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
......@@ -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)
......
......@@ -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++)
{
......
......@@ -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++)
{
......
......@@ -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] ) ;
......
......@@ -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]
......
......@@ -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++) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment