-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathshowres
executable file
·90 lines (75 loc) · 2.45 KB
/
showres
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
#Showres: show summary of reservation status (Slurm version)
#Author: Si Liu (siliu@tacc.utexas.edu)
#Author: Niall Gaffney (ngaffney@tacc.utexas.edu)
#Last modified: May 18, 2016
OPTIND=1
all=0 #Whether check all reservations
myself=1 #Whether check my own reservations
TheUser=${USER}
currenthost=`hostname -f`
if [[ $currenthost == *"ls5"* ]]
then
# echo "Lonestar 5"
SCONTROL_CMD="/opt/slurm/default/bin/scontrol"
else
# echo "other systems"
SCONTROL_CMD="/usr/bin/scontrol"
fi
while getopts "ahu:" opt; do
case "$opt" in
a) all=1
break
;;
u)
TheUser=$OPTARG
;;
h)
echo "Usage: $0 [OPTION] "
echo "list current reservations in a clean format:"
echo " -a : list reservation(s) for all users on system"
echo " -u : list reservation(s) for a specific user"
echo " -h : prints this message"
exit 0
;;
\?)
echo "Usage: $0 [OPTION] "
echo "list current reservations in a clean format:"
echo " -a : list reservation(s) for all users on system"
echo " -u : list reservation(s) for a specific user"
echo " -h : prints this message"
exit 0
;;
esac
done
if [ $all == 1 ]
then
res_info=`$SCONTROL_CMD -o show res`
else
res_info=`$SCONTROL_CMD -o show res | /bin/grep --word-regexp ${TheUser}`
fi
if [ -z "$res_info" ]
then
echo "No reservation found!"
exit 0
fi
if [ "$res_info" == "No reservations in the system" ]
then
echo "No reservation found!"
exit 0
fi
#Si should merge the "no reservation check into the commands below!
if [ $all == 1 ]
then
$SCONTROL_CMD -o show res | /bin/awk '\
BEGIN {FS="=| "; \
printf "%-23s %9s %12s %7s %12s %12s %9s\n", \
"Reservation Name", "State", "Queue", "#Nodes", "Start Time", "End time", "Duration"} \
{printf("%-23s %9s %12s %7s %12s %12s %9s\n", substr($2,0,23), $31, $18, $12, substr($4,6,11), substr($6,6,11), substr($8,0,length($8)-3) ) }'
else
$SCONTROL_CMD -o show res | grep --word-regexp ${TheUser} | /bin/awk '\
BEGIN {FS="=| "; \
printf "%-23s %9s %12s %7s %12s %12s %9s\n", \
"Reservation Name", "State", "Queue", "#Nodes", "Start Time", "End time", "Duration"} \
{printf("%-23s %9s %12s %7s %12s %12s %9s\n", substr($2,0,23), $31, $18, $12, substr($4,6,11), substr($6,6,11), substr($8,0,length($8)-3) )}'
fi