Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sorting prio output and retaining header #2

Open
gajowi opened this issue Jan 16, 2015 · 0 comments
Open

sorting prio output and retaining header #2

gajowi opened this issue Jan 16, 2015 · 0 comments

Comments

@gajowi
Copy link

gajowi commented Jan 16, 2015

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant