diff --git a/AUTHORS b/AUTHORS index 5b5cae41214da9425edc71a9c94302b328c4fa32..e032b3b94bfc7da3a66ddb4bbb08930c1f7c3f0d 100644 --- a/AUTHORS +++ b/AUTHORS @@ -28,5 +28,6 @@ Ashley Pitman <ashley@quadrics.com> Andy Riebs <Andy.Riebs@hp.com> Jeff Squyres <jsquyres@lam-mpi.org> Keven Tew <tew1@llnl.gov> +Prashanth Tamraparni <prashanth.tamraparni@hp.com> Jay Windley <jwindley@lnxi.com> Ann-Marie Wunderlin<Anne-Marie.Wunderlin@Bull.com> diff --git a/NEWS b/NEWS index 99f8814450cf1f2c32eab7f0d55a1f28716a662f..19873162663e287f6b23e69a15f0a0de394d7556 100644 --- a/NEWS +++ b/NEWS @@ -3,7 +3,8 @@ documents those changes that are of interest to users and admins. * Changes in SLURM 1.2.9 ======================== - + -- Add new sinfo field to sort by "%E" sorts by the time associated with a + node's state (from Prashanth Tamraparni, HP). * Changes in SLURM 1.2.8 ======================== diff --git a/doc/man/man1/sinfo.1 b/doc/man/man1/sinfo.1 index 889ad726145cd35719f8177427adf5ff58af43da..c9a0326e9d87ef4648460868f4bc7ce38d8cad7a 100644 --- a/doc/man/man1/sinfo.1 +++ b/doc/man/man1/sinfo.1 @@ -130,6 +130,11 @@ Size of temporary disk space per node in megabytes \fB%D\fR Number of nodes .TP +\fB%E\fR +The reason a node is unavailable (down, drained, or draining states). +This is the same as \fB%R\fR except the entries will be sorted by +time rather than the reason string. +.TP \fB%f\fR Features associated with the nodes .TP diff --git a/src/sinfo/opts.c b/src/sinfo/opts.c index 2e7c64aa0f9334d9e2d1e87687b9d414fea4d254..a01a349d487deb0b3c0ea1fd22c4978904217024 100644 --- a/src/sinfo/opts.c +++ b/src/sinfo/opts.c @@ -475,7 +475,9 @@ _parse_format( char* format ) field_size, right_justify, suffix ); - } else if (field[0] == 'f') { + } +/* else if (field[0] == 'E') see 'R' below */ + else if (field[0] == 'f') { params.match_flags.features_flag = true; format_add_features( params.format_list, field_size, @@ -527,7 +529,7 @@ _parse_format( char* format ) field_size, right_justify, suffix ); - } else if (field[0] == 'R') { + } else if ((field[0] == 'E') || (field[0] == 'R')) { params.match_flags.reason_flag = true; format_add_reason( params.format_list, field_size, diff --git a/src/sinfo/sort.c b/src/sinfo/sort.c index bdb6cbae91cb72c9147150689a301ba7954a4b65..08303757f509a1cf1890b53e00d7a53681e3d82d 100644 --- a/src/sinfo/sort.c +++ b/src/sinfo/sort.c @@ -1,7 +1,7 @@ /*****************************************************************************\ * sort.c - sinfo sorting functions ***************************************************************************** - * Copyright (C) 2002-2006 The Regents of the University of California. + * Copyright (C) 2002-2007 The Regents of the University of California. * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). * Written by Joey Ekstrom <ekstrom1@llnl.gov>, * Morris Jette <jette1@llnl.gov>, et. al. @@ -64,6 +64,7 @@ static int _sort_by_nodes_ai(void *void1, void *void2); static int _sort_by_nodes(void *void1, void *void2); static int _sort_by_partition(void *void1, void *void2); static int _sort_by_reason(void *void1, void *void2); +static int _sort_by_reason_time(void *void1, void *void2); static int _sort_by_root(void *void1, void *void2); static int _sort_by_share(void *void1, void *void2); static int _sort_by_state(void *void1, void *void2); @@ -105,6 +106,8 @@ void sort_sinfo_list(List sinfo_list) list_sort(sinfo_list, _sort_by_disk); else if (params.sort[i] == 'D') list_sort(sinfo_list, _sort_by_nodes); + else if (params.sort[i] == 'E') + list_sort(sinfo_list, _sort_by_reason_time); else if (params.sort[i] == 'f') list_sort(sinfo_list, _sort_by_features); else if (params.sort[i] == 'F') @@ -465,6 +468,39 @@ static int _sort_by_reason(void *void1, void *void2) return diff; } +/* Sort by the time associated with the reason (if any). + * If no time, sort by the "reason" string. + * "reason" is of the format "<reason[<user>@MM/DD-HH:MM_SS]" + * or (ISO8601) "<reason[<user>@YYYY-MM-DDTHH:MM:SS]" + * In either case a simple string compare sort order the records. */ +static int _sort_by_reason_time(void *void1, void *void2) +{ + int diff; + sinfo_data_t *sinfo1 = (sinfo_data_t *) void1; + sinfo_data_t *sinfo2 = (sinfo_data_t *) void2; + char *tmp, *val1 = "", *val2 = ""; + + if (sinfo1->reason) { + tmp = strrchr(sinfo1->reason, '@'); + if (tmp) + val1 = tmp + 1; + else + val1 = sinfo1->reason; + } + if (sinfo2->reason) { + tmp = strrchr(sinfo2->reason, '@'); + if (tmp) + val2 = tmp + 1; + else + val2 = sinfo2->reason; + } + diff = strcmp(val1, val2); + + if (reverse_order) + diff = -diff; + return diff; +} + static int _sort_by_root(void *void1, void *void2) { int diff;