diff --git a/doc/man/man1/sacct.1 b/doc/man/man1/sacct.1 index bd541c58fb581a2d02fe433ef0bb0e3ece658dfe..2a149ff3acd5a2e13ae90161c374766d75ae826f 100644 --- a/doc/man/man1/sacct.1 +++ b/doc/man/man1/sacct.1 @@ -230,15 +230,16 @@ option. .nf .ft 3 Fields available: - cpu elapsed exitcode blockid - gid group idrss inblocks - isrss ixrss job jobname - jobid majflt minflt msgrcv - msgsnd ncpus nivcsw nodes - ntasks nsignals nswap cputime - nvcsw outblocks partition vsize - rss status submitted systemcpu - uid user usercpu +cpu elapsed exitcode gid +group idrss inblocks isrss +ixrss job jobname jobid +majflt minflt msgrcv msgsnd +ncpus nivcsw nodes nprocs +ntasks nsignals nswap nvcsw +outblocks partition blockid rss +pages status submit start +end systemcpu uid user +usercpu vsize cputime .ft 1 .fi @@ -511,7 +512,7 @@ Output can be The time and date stamp (in Universal Time Coordinated, UTC) the job was submitted. The format of the output is identical to that of the -\f3finished\fP +\f3end\fP field. .TP \f3systemcpu\fP @@ -681,7 +682,7 @@ The number of fields in the record (38) \f3jobid\fP .TP 11 -\f3finished\fP +\f3end\fP .TP 12 Completion Status; @@ -843,7 +844,7 @@ command aggregates the remainder. The total elapsed time in seconds for the job. .TP 11 -\f3finished\fP +\f3end\fP .TP 12 Completion Status; diff --git a/src/sacct/options.c b/src/sacct/options.c index d651464cd0a70e64a958f41710c843e24fe6bd1a..fd38223ef56e96155db54deebcc24d3e27d1c63c 100644 --- a/src/sacct/options.c +++ b/src/sacct/options.c @@ -32,7 +32,7 @@ typedef struct expired_rec { /* table of expired jobs */ uint32_t job; - time_t job_start; + time_t job_submit; char *line; } expired_rec_t; @@ -108,7 +108,7 @@ int _cmp_jrec(const void *a1, const void *a2) { if (j1->job < j2->job) return -1; else if (j1->job == j2->job) { - if(j1->job_start == j2->job_start) + if(j1->job_submit == j2->job_submit) return 0; else return 1; @@ -134,7 +134,7 @@ void _dump_header(acct_header_t header) ts.tm_hour, ts.tm_min, ts.tm_sec, - (int)header.job_start, + (int)header.job_submit, header.blockid, /* block id */ "-"); /* reserved 1 */ } @@ -208,7 +208,7 @@ void _help_msg(void) " isn't reset at the same time (with -e, for example), some\n" " job numbers will probably appear more than once in the\n" " accounting log file to refer to different jobs; such jobs\n" - " can be distinguished by the \"job_start\" time stamp in the\n" + " can be distinguished by the \"job_submit\" time stamp in the\n" " data records.\n" " When data for specific jobs are requested with\n" " the --jobs option, we assume that the user\n" @@ -1045,7 +1045,6 @@ void do_dump(void) job_rec_t *job = NULL; step_rec_t *step = NULL; struct tm ts; - time_t finished; itr = list_iterator_create(jobs); while((job = list_next(itr))) { @@ -1056,7 +1055,7 @@ void do_dump(void) "Note: Skipping older" " job %u dated %d\n", job->header.jobnum, - (int)job->header.job_start); + (int)job->header.job_submit); continue; } if (params.opt_uid>=0) @@ -1101,8 +1100,7 @@ void do_dump(void) step->exitcode=1; } _dump_header(step->header); - finished=step->header.job_start+step->elapsed; - gmtime_r(&finished, &ts); + gmtime_r(&step->end, &ts); printf("JOB_STEP 1 50 %u %04d%02d%02d%02d%02d%02d ", step->stepnum, 1900+(ts.tm_year), 1+(ts.tm_mon), ts.tm_mday, @@ -1158,8 +1156,7 @@ void do_dump(void) /* JOB_TERMINATED */ if (job->show_full) { _dump_header(job->header); - finished=job->header.job_start+job->elapsed; - gmtime_r(&finished, &ts); + gmtime_r(&job->end, &ts); printf("JOB_TERMINATED 1 50 %d ", job->elapsed); printf("%04d%02d%02d%02d%02d%02d ", @@ -1330,7 +1327,7 @@ void do_expire(void) } exp_rec->job = atoi(f[F_JOB]); - exp_rec->job_start = atoi(f[F_JOB_START]); + exp_rec->job_submit = atoi(f[F_JOB_SUBMIT]); rec_type = atoi(f[F_RECTYPE]); /* Odd, but complain some other time */ @@ -1354,7 +1351,7 @@ void do_expire(void) if (params.opt_verbose > 2) fprintf(stderr, "Selected: %8d %d\n", exp_rec->job, - (int)exp_rec->job_start); + (int)exp_rec->job_submit); } else { list_append(other_list, exp_rec); } @@ -1420,7 +1417,7 @@ void do_expire(void) itr2 = list_iterator_create(other_list); while((exp_rec2 = list_next(itr2))) { if((exp_rec2->job != exp_rec->job) - || (exp_rec2->job_start != exp_rec->job_start)) + || (exp_rec2->job_submit != exp_rec->job_submit)) continue; if (fputs(exp_rec2->line, expired_logfile)<0) { perror("writing expired_logfile"); @@ -1540,7 +1537,7 @@ void do_fdump(char* f[], int lc) char **type; char *header[] = {"job", /* F_JOB */ "partition", /* F_PARTITION */ - "job_start", /* F_JOB_START */ + "job_submit", /* F_JOB_SUBMIT */ "timestamp", /* F_TIMESTAMP */ "uid", /* F_UIDGID */ "gid", /* F_UIDGID */ @@ -1687,7 +1684,7 @@ void do_list(void) "Note: Skipping older" " job %u dated %d\n", job->header.jobnum, - (int)job->header.job_start); + (int)job->header.job_submit); continue; } if (!job->job_start_seen && job->job_step_seen) { diff --git a/src/sacct/print.c b/src/sacct/print.c index 48c29fd8f4ed80d8a22b43f3506281368d4be993..5442646c82831e8083b2cab9361c7abc89edce91 100644 --- a/src/sacct/print.c +++ b/src/sacct/print.c @@ -27,6 +27,7 @@ \*****************************************************************************/ #include "sacct.h" +#include "src/common/parse_time.h" #define FORMAT_STRING_SIZE 32 char *_decode_status(int status); @@ -786,23 +787,86 @@ void print_status(type_t type, void *object) } } -void print_submitted(type_t type, void *object) +void print_submit(type_t type, void *object) { job_rec_t *job = (job_rec_t *)object; step_rec_t *step = (step_rec_t *)object; + char time_str[32]; + + switch(type) { + case HEADLINE: + printf("%-14s", "Submit Time"); + break; + case UNDERSCORE: + printf("%-14s", "--------------"); + break; + case JOB: + slurm_make_time_str(&job->header.job_submit, + time_str, + sizeof(time_str)); + printf("%-14s", time_str); + break; + case JOBSTEP: + slurm_make_time_str(&step->header.timestamp, + time_str, + sizeof(time_str)); + printf("%-14s", time_str); + break; + } +} + +void print_start(type_t type, void *object) +{ + job_rec_t *job = (job_rec_t *)object; + step_rec_t *step = (step_rec_t *)object; + char time_str[32]; + + switch(type) { + case HEADLINE: + printf("%-14s", "Start Time"); + break; + case UNDERSCORE: + printf("%-14s", "--------------"); + break; + case JOB: + slurm_make_time_str(&job->header.timestamp, + time_str, + sizeof(time_str)); + printf("%-14s", time_str); + break; + case JOBSTEP: + slurm_make_time_str(&step->header.timestamp, + time_str, + sizeof(time_str)); + printf("%-14s", time_str); + break; + } +} +void print_end(type_t type, void *object) +{ + job_rec_t *job = (job_rec_t *)object; + step_rec_t *step = (step_rec_t *)object; + char time_str[32]; + switch(type) { case HEADLINE: - printf("%-14s", "Submitted"); + printf("%-14s", "End Time"); break; case UNDERSCORE: printf("%-14s", "--------------"); break; case JOB: - printf("%-14d", (int)job->header.job_start); + slurm_make_time_str(&job->end, + time_str, + sizeof(time_str)); + printf("%-14s", time_str); break; case JOBSTEP: - printf("%-14d", (int)step->header.job_start); + slurm_make_time_str(&step->end, + time_str, + sizeof(time_str)); + printf("%-14s", time_str); break; } } diff --git a/src/sacct/process.c b/src/sacct/process.c index c7d5cd7df7e05689304382a8d8b60cab1cf1a856..eb38f3c1ecef15e055f663d9aef559085b46b65b 100644 --- a/src/sacct/process.c +++ b/src/sacct/process.c @@ -41,12 +41,12 @@ job_rec_t *_find_job_record(acct_header_t header) while((job = (job_rec_t *)list_next(itr)) != NULL) { if (job->header.jobnum == header.jobnum) { - if(job->header.job_start == BATCH_JOB_TIMESTAMP) { - job->header.job_start = header.job_start; + if(job->header.job_submit == BATCH_JOB_TIMESTAMP) { + job->header.job_submit = header.job_submit; break; } - if(job->header.job_start == header.job_start) + if(job->header.job_submit == header.job_submit) break; else { /* If we're looking for a later @@ -134,7 +134,7 @@ int _parse_header(char *f[], acct_header_t *header) { header->jobnum = atoi(f[F_JOB]); header->partition = xstrdup(f[F_PARTITION]); - header->job_start = atoi(f[F_JOB_START]); + header->job_submit = atoi(f[F_JOB_SUBMIT]); header->timestamp = atoi(f[F_TIMESTAMP]); header->uid = atoi(f[F_UID]); header->gid = atoi(f[F_GID]); @@ -301,6 +301,7 @@ void process_step(char *f[], int lc, int show_full) memcpy(&step->sacct, &temp->sacct, sizeof(sacct_t)); xfree(step->stepname); step->stepname = xstrdup(temp->stepname); + step->end = temp->header.timestamp; destroy_step(temp); goto got_step; } @@ -323,9 +324,8 @@ got_step: status */ if ( job->exitcode == 0 ) job->exitcode = step->exitcode; - job->header.timestamp = step->header.timestamp; job->status = JOB_RUNNING; - job->elapsed = time(NULL) - job->header.timestamp; + job->elapsed = step->header.timestamp - job->header.timestamp; } /* now aggregate the aggregatable */ job->ncpus = MAX(job->ncpus, step->ncpus); @@ -379,7 +379,7 @@ void process_suspend(char *f[], int lc, int show_full) if (job->status == JOB_SUSPENDED) job->elapsed -= temp->elapsed; - job->header.timestamp = temp->header.timestamp; + //job->header.timestamp = temp->header.timestamp; job->status = temp->status; destroy_job(temp); } @@ -425,7 +425,7 @@ void process_terminated(char *f[], int lc, int show_full) } job->job_terminated_seen = 1; job->elapsed = temp->elapsed; - job->header.timestamp = temp->header.timestamp; + job->end = temp->header.timestamp; job->status = temp->status; if(list_count(job->steps) > 1) job->track_steps = 1; diff --git a/src/sacct/sacct.c b/src/sacct/sacct.c index b06800c4a8e7caaaf1e440eb789f996ec5e00b04..dd97180189904e64ae163efa4bc00f146f69d02a 100644 --- a/src/sacct/sacct.c +++ b/src/sacct/sacct.c @@ -169,7 +169,9 @@ fields_t fields[] = {{"cpu", print_cpu}, {"rss", print_rss}, {"pages", print_pages}, {"status", print_status}, - {"submitted", print_submitted}, + {"submit", print_submit}, + {"start", print_start}, + {"end", print_end}, {"systemcpu", print_systemcpu}, {"uid", print_uid}, {"user", print_user}, diff --git a/src/sacct/sacct.h b/src/sacct/sacct.h index 711f49cb31071629f5e948c74e7e1a5cace371c5..b1d3e13f477d00f22dad7188121e47376e4975d0 100644 --- a/src/sacct/sacct.h +++ b/src/sacct/sacct.h @@ -77,7 +77,7 @@ /* Fields common to all records */ enum { F_JOB = 0, F_PARTITION, - F_JOB_START, + F_JOB_SUBMIT, F_TIMESTAMP, F_UID, F_GID, @@ -168,7 +168,7 @@ typedef struct header { uint32_t jobnum; char *partition; char *blockid; - time_t job_start; + time_t job_submit; time_t timestamp; uint32_t uid; uint32_t gid; @@ -191,6 +191,7 @@ typedef struct job_rec { int32_t status; int32_t exitcode; uint32_t elapsed; + time_t end; uint32_t tot_cpu_sec; uint32_t tot_cpu_usec; struct rusage rusage; @@ -208,6 +209,7 @@ typedef struct step_rec { uint32_t ntasks; uint32_t ncpus; uint32_t elapsed; + time_t end; uint32_t tot_cpu_sec; uint32_t tot_cpu_usec; struct rusage rusage; @@ -300,7 +302,9 @@ void print_blockid(type_t type, void *object); void print_pages(type_t type, void *object); void print_rss(type_t type, void *object); void print_status(type_t type, void *object); -void print_submitted(type_t type, void *object); +void print_submit(type_t type, void *object); +void print_start(type_t type, void *object); +void print_end(type_t type, void *object); void print_systemcpu(type_t type, void *object); void print_uid(type_t type, void *object); void print_user(type_t type, void *object);