-
Notifications
You must be signed in to change notification settings - Fork 2
/
jobsu
executable file
·38 lines (30 loc) · 898 Bytes
/
jobsu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
# print SU usage for a given job ID
# Ruoshi Sun
# 2024-03-12
if [ $# -ne 1 ]; then
echo "Usage: `basename $0` JobID"
exit 1
fi
JOBID=$1
read -r NAME ACCOUNT STATE START END ELAPSED CORE < <(sacct -j $JOBID -no user,account%30,state,start,end,elapsed,alloccpus)
if [ -z "$STATE" ]; then
echo "No such job"
exit 1
fi
echo " User: $NAME"
echo "Allocation: $ACCOUNT"
echo " State: $STATE"
echo " Start: $START"
echo " End: $END"
echo -e "\e[1m Elapsed: $ELAPSED"
echo -e " Cores: $CORE\e[0m"
if [ "$END" = "Unknown" ]; then
echo -e " SU: (TBD)"
exit
fi
MAMSTART=$(echo $START|sed 's/T.*$//')
read -r AMOUNT DELTA BALANCE < <(sudo /opt/mam/current/bin/mam-list-transactions -J $JOBID -s $MAMSTART | awk 'END{print $9,$10,$11}')
echo -e "\e[1;31m SU: $AMOUNT\e[0m"
echo " Delta: $DELTA"
echo " Balance: $BALANCE"