From 9101c9a6ec16882ad4232b4cb13ff73d220665c2 Mon Sep 17 00:00:00 2001
From: William Warriner <wwarr@uab.edu>
Date: Fri, 1 Nov 2024 10:56:53 -0500
Subject: [PATCH] modify default time and provide feedback

---
 scontext.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/scontext.sh b/scontext.sh
index d8fdc71..a5ddb03 100755
--- a/scontext.sh
+++ b/scontext.sh
@@ -2,7 +2,7 @@
 
 #set -euo
 
-pidstat_recording_duration=${1:-0}
+pidstat_recording_duration=${1:-5}
 
 if [ $pidstat_recording_duration -eq 0 ]; then
   pidstat_recording_count=""
@@ -30,6 +30,8 @@ ps_header=$(ps -eo "pid,user,cp,drs,cmd" | head -n 1)
 pidstat_header=$(pidstat -w | awk 'NR==3 {print $4, $5, $6}')
 scontrol_header=$(scontrol listpids | head -n 1)
 
+echo -e "Observing for $pidstat_recording_duration seconds..."
+
 # Sort the outputs by PID, excluding headers
 ps_sorted=$(ps -eo "pid,user,cp,drs,cmd" | tail -n +2 | sort -k$PS_PID_COL,$PS_PID_COL)
 pidstat_sorted=$( \
@@ -96,6 +98,8 @@ squeue_header=$(echo "$squeue_header" | sed 's/JOBID/JOB_ARRAY_ID/2' | sed 's/MI
 output_header=$(echo "$squeue_header ctx-sw/s nvctx-sw/s total/s threads" | sed 's/ \+/ /g')
 output_body=$(join -1 1 -2 1 <(echo "$squeue_body") <(echo "$agg") | sort -k1,1 | sed 's/ \+/ /g')
 
+tput cuu 1
+
 printf "%10s %16s %16s %12s %12s %5s %15s %15s %15s %8s\n" $output_header
 for element in "${output_body[@]}"; do
     printf "%10s %16s %16s %12s %12s %5s %15.2f %15.2f %15.2f %8s\n" $element
-- 
GitLab