-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmyaccount
executable file
·68 lines (56 loc) · 2.06 KB
/
myaccount
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env bash
# myaccount
# Display Slurm account information for user
set -e -o pipefail
if [[ -z $1 ]]; then
user=$USER
else
user=$1
# Check if user exists
if [[ "$(id $user 2>&1)" = *"no such user"* ]]; then
printf "%s\n" "No such user: $user"
exit 1
fi
fi
# Display table of Discovery and Endeavour accounts
printf "%s\n" "----------------------------------------------------------------"
printf "%s\n" "Project accounts"
printf "%s\n" "----------------------------------------------------------------"
printf "%s\n" "User Account Cluster Def Acct QOS"
printf "%s\n" "---------- --------------- ---------- --------------- ----------"
sacctmgr list user $user -n -s cluster=h4huhn format=user%-10,account%-15,cluster%-10,defaultaccount%-15,qos%-10
printf "%s\n" ""
set +e
# Collect Discovery accounts in array
accounts=()
for i in $(sacctmgr list user $user -n -s cluster=h4huhn format=account%19d); do
accounts+=($i)
done
# Collect billing limits for each Discovery account in array
limits=()
for i in ${accounts[@]}; do
tmp=$(sshare -n -M h4huhn -o grptresmins -A $i | grep -m 1 -o "billing=[0-9]*")
if [[ $tmp == "" ]]; then
limits+=("inactive") # expired or unlimited
else
limits+=($tmp)
fi
done
# Collect current total usage for each Discovery account in array
usage=()
for i in ${accounts[@]}; do
usage+=($(sshare -n -M h4huhn -o grptresraw%100 -A $i | grep -m 1 -o "billing=[0-9]*"))
done
# Display table of Discovery account limits and usage
printf "%s\n" "-----------------------------------------------------"
printf "%s\n" "Discovery compute allocations"
printf "%s\n" "-----------------------------------------------------"
paste <(printf "%s\n" "Account" "---------------" ${accounts[@]}) \
<(printf "%s\n" "Limit" "-----------------" ${limits[@]}) \
<(printf "%s\n" "Usage" "-----------------" ${usage[@]}) |
column -ts $'\t'
# Display allowed partitions on Endeavour
if [[ $HOSTNAME == *"h4huhn"* ]]; then
printf "%s\n" ""
mypartitions $user
fi