Skip to content

sorting prio output and retaining header #2

@gajowi

Description

@gajowi

I have local customizations to sort priority output that I'd be glad to contribute. I just tried emailing but was blocked so I'm pasting info here.

  1. we are using the 'nice' parameter in priority setting so I changed format to report it. That is probably not of general interest and I can maintain it as a local mod.
  2. I added code to sort priority output

The output sorting with header retention could be useful more generally and may avoid the need to hard code custom headers.

Also I noticed that the comment about ~/.slurmvars is probably not right - should be ~/.config/slurmvars

Thanks,

Gareth

> diff -Naur `which slurm` slurm
--- /apps/scutils/bin/slurm     2015-01-12 10:30:27.569737600 +1100
+++ slurm       2015-01-16 12:20:22.302605038 +1100
@@ -24,9 +24,9 @@
 fmt_full="%Q %i %P %j %u %C %D %m %f %q %h %t %M %l %R"
 fmt_s_parts="%10P %.11l %.15F %10f %N"
 fmt_s_nodes="%.5D %.10T %.4c %.7m %10f %N"
-fmt_s_prio="%.8u %.10Y %.10F %.10J %.10A %.10Q %.12P"
-fmt_s_prio_all="%.8u %.12i %.10Y %.10F %.10J %.10A %.10Q %.12P"
-fmt_s_prio_user="%.12i %.10Y %.10F %.10J %.10A %.10Q %.12P"
+fmt_s_prio="%.8u %.10Y %.10F %.10J %.10A %.10Q %.12P %10N"
+fmt_s_prio_all="%.8u %.12i %.10Y %.10F %.10J %.10A %.10Q %.12P %10N"
+fmt_s_prio_user="%.12i %.10Y %.10F %.10J %.10A %.10Q %.12P %10N"
 if [ -r $user_vars ]; then source $user_vars; fi

 fmt_s_stat="jobid,avevmsize,averss,maxvmsize,maxrss,ntasks,nodelist"
@@ -55,6 +55,17 @@
 clean="/usr/bin/column -t"
 prune="/bin/grep -v '\ 0\ \ '"

+# idea from http://unix.stackexchange.com/questions/11856/sort-but-keep-header-line-at-the-top
+retainhead() {
+    IFS= read -r header
+    printf '%s\n' "$header"
+    "$@"
+}
+
+priosort() {
+    retainhead sort -rnk 3
+}
+
 function usage {
     self=`basename $0`
     cat <<EOF
@@ -155,7 +166,7 @@
                    cmd="$cmd_prio '$fmt_s_prio' | $merge | $clean"
                    ;;
                a|all)
-                   cmd="$cmd_prio '$fmt_s_prio_all' | $clean"
+                   cmd="$cmd_prio '$fmt_s_prio_all' | priosort | $clean"
                    ;;
                *)
                    if [ "$2" ]; then

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions