-
Notifications
You must be signed in to change notification settings - Fork 1
/
ss
executable file
·87 lines (81 loc) · 2.47 KB
/
ss
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
set -o errexit -o noclobber -o nounset -o pipefail
params="$(getopt -o prmgtfh -l pending,running,mine,gres,table,fixed-width,help --name "$0" -- "$@")"
eval set -- "$params"
states='all'
users=''
makecolumn=1
# partition user time-limit job-state cpus
# id name time-left start-time nodes reason
format='%i;%P;%j;%u;%L;%l;%S;%t;%D;%C;%R'
# partition user time-limit job-state cpus
# id name time-left start-time nodes reason
fixfmt='%10.10s %10.10s %10.10s %10.10s %12.12s %12.12s %12.12s %5.5s %5.5s %5.5s %12.12s'
fixarg='$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11'
while true
do
case "$1" in
-p|--pending )
#Pending
states='PD'
shift
;;
-r|--running )
# Running
states='R'
shift
;;
-m|--mine )
# Mine
users="-u $USER"
shift
;;
-g|--gres )
# Show gres column (gpus)
format="$format;%b"
fixfmt="$fixfmt %5s"
fixarg="$fixarg, \$12"
shift
;;
-t|--table )
makecolumn=1
shift
;;
-f|--fixed-width )
makecolumn=0
shift
;;
-h|--help )
echo "Usage: ss [options] -- [squeue options]"
echo ""
echo -e "Options"
echo -e "\t -p, --pending pending"
echo -e "\t -r, --running running"
echo -e "\t -m, --mine my jobs"
echo -e "\t -g, --gres show gres (GPU) column"
echo -e ""
echo -e "\t -t, --table"
echo -e "\t -f, --fixed-width Adapt column widths (table) or"
echo -e "\t truncate (fixed-width)"
echo -e ""
echo -e "\t -h, --help this message"
echo ""
exit 1
;;
-- )
shift
break
;;
* )
echo "Unknown option: $1" >&2
exit 2
;;
esac
done
if [ $makecolumn -eq 1 ]
then
squeue --format="$format" --sort="t,-S" --states=$states $users $@ | column -t -s ';'
else
fixfmt="\"$fixfmt\\n\""
squeue --format="$format" --sort="t,-S" --states=$states $users $@ | awk -F ';' "{printf($fixfmt, $fixarg)}"
fi