diff --git a/src/sreport/Makefile.am b/src/sreport/Makefile.am index a4bf7fccb98431dd184120e564b1488a31b00ba5..787edb2570817e4be61e3f1cc76e57c5c89170c5 100644 --- a/src/sreport/Makefile.am +++ b/src/sreport/Makefile.am @@ -7,7 +7,10 @@ INCLUDES = -I$(top_srcdir) bin_PROGRAMS = sreport sreport_SOURCES = \ - sreport.c sreport.h + sreport.c sreport.h \ + cluster_reports.c cluster_reports.h \ + assoc_reports.c assoc_reports.h \ + common.c common.h sreport_LDADD = \ $(top_builddir)/src/common/libcommon.o -ldl \ diff --git a/src/sreport/assoc_reports.c b/src/sreport/assoc_reports.c new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/sreport/assoc_reports.h b/src/sreport/assoc_reports.h new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/sreport/cluster_reports.c b/src/sreport/cluster_reports.c new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/sreport/cluster_reports.h b/src/sreport/cluster_reports.h new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/sreport/common.c b/src/sreport/common.c new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/sreport/common.h b/src/sreport/common.h new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/sreport/sreport.c b/src/sreport/sreport.c index c3dfb8223eaf579769e4c88352147e9bd382ddf9..a215f1fb56513f79e4aa0becee8ac91e2b267761 100644 --- a/src/sreport/sreport.c +++ b/src/sreport/sreport.c @@ -50,12 +50,14 @@ int one_liner; /* one record per line if =1 */ int quiet_flag; /* quiet=1, verbose=-1, normal=0 */ int rollback_flag; /* immediate execute=1, else = 0 */ int with_assoc_flag = 0; +sreport_time_format_t time_format = SREPORT_TIME_SECS; void *db_conn = NULL; uint32_t my_uid = 0; static int _get_command (int *argc, char *argv[]); static void _print_version( void ); static int _process_command (int argc, char *argv[]); +static int _set_time_format(char *format); static void _usage (); int @@ -319,6 +321,15 @@ _process_command (int argc, char *argv[]) argv[0]); } exit_flag = 1; + } else if (strncasecmp (argv[0], "time", 1) == 0) { + if (argc < 2) { + exit_code = 1; + fprintf (stderr, + "too few arguments for keyword:%s\n", + argv[0]); + } + _set_time_format(argv[1]); + quiet_flag = -1; } else if (strncasecmp (argv[0], "verbose", 4) == 0) { if (argc > 1) { exit_code = 1; @@ -343,6 +354,27 @@ _process_command (int argc, char *argv[]) return 0; } +static int _set_time_format(char *format) +{ + if (strncasecmp (format, "SecPer", 6) == 0) { + time_format = SREPORT_TIME_SECS_PER; + } else if (strncasecmp (format, "Sec", 1) == 0) { + time_format = SREPORT_TIME_SECS; + } else if (strncasecmp (format, "FormattedPer", 12) == 0) { + time_format = SREPORT_TIME_FORMATTED_PER; + } else if (strncasecmp (format, "Formatted", 1) == 0) { + time_format = SREPORT_TIME_FORMATTED; + } else if (strncasecmp (format, "Percent", 1) == 0) { + time_format = SREPORT_TIME_PERCENT; + } else { + fprintf (stderr, "unknown time format %s", format); + return SLURM_ERROR; + } + + return SLURM_SUCCESS; +} + + /* _usage - show the valid sreport commands */ void _usage () { printf ("\ diff --git a/src/sreport/sreport.h b/src/sreport/sreport.h index 034f03e5cd37c11cf96bf3ee69cecb355b862824..67880acf45d4fdd44d00c0d058109d0f4e33597f 100644 --- a/src/sreport/sreport.h +++ b/src/sreport/sreport.h @@ -85,4 +85,14 @@ #define CKPT_WAIT 10 #define MAX_INPUT_FIELDS 128 +typedef enum { + SREPORT_TIME_SECS, + SREPORT_TIME_PERCENT, + SREPORT_TIME_FORMATTED, + SREPORT_TIME_SECS_PER, + SREPORT_TIME_FORMATTED_PER +} sreport_time_format_t; + +extern sreport_time_format_t time_format; + #endif /* HAVE_SREPORT_H */