diff --git a/scontext.sh b/scontext.sh index d8fdc7155111d055c24ea35f6ebf8ff20d7947fb..a5ddb03b21b2cd3cbcc92d6008e30a1cfd0bebc3 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