forked from siliu-tacc/sanitytool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
whyblock
executable file
·123 lines (104 loc) · 4.28 KB
/
whyblock
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/bash
#version: sanitytool 1.3
#Last updated on Apr 11
# Small tools checking whether and why a user is blocked on TACC System.
# Please contact Si Liu ([email protected])
# If you have any questions or concerns.
if [ "$#" -ne 1 ];
then
echo "Illegal number of parameters!"
echo " Please launch the command as: whyblock joe"
echo " or list all blocked users by: whyblock all"
echo " "
echo " Contact Si Liu ([email protected]) for any questions or concerns."
exit
fi
if [ "$1" == "-h" ] || [ "$1" == "-H" ] || [ "$1" == "--help" ] ;
then
echo "TACC tool to check why a user is blocked on TACC Systems"
echo "Current supported system: Stampede, Maverick, Lonestar5"
echo "Please launch the command as: whyblock joe"
echo "or list all users prevented from submission: whyblock all"
echo "whyblock -h or whyblock --help for this help information"
echo " "
echo "Contact Si Liu ([email protected]) for any questions or concerns."
exit
fi
currenthost=`hostname -f`
echo $currenthost
if [[ $currenthost == *"ls5"* ]]; then
block_list="/opt/apps/tacc/bin/tacc_filter_options"
else
if [[ $currenthost == *"stampede"* ]]; then
block_list="/etc/slurm/tacc_filter_options"
else
if [[ $currenthost == *"maverick"* ]]; then
block_list="/etc/slurm/tacc_filter_options"
else
echo "This system is not supported!"
exit
fi
fi
fi
## May NEED to reduce some code duplication when possible
if [ "$1" == "all" ] || [ "$1" == "All" ] || [ "$1" == "ALL" ] ;
then
echo "Users who can not submit jobs:"
grep "ALL" $block_list
echo ""
if [[ $currenthost == *"stampede"* ]]
then
echo "users who can not use largememory queue"
grep "^largemem" $block_list
echo ""
echo "user who can not Xeon-Phi queue"
grep "^normal-" $block_list
fi
exit
fi
user=`echo $1 | tr '[:upper:]' '[:lower:]'`
userinfo=`/bin/awk -F: -v user="$user" '$1 == user {print $0}' </etc/passwd `
if [[ -z $userinfo ]]; then
echo "$user is not a known user."
exit
else
echo -e "User info:\n"$userinfo
echo ""
fi
### Can not login: blocked by System administrators
block_login=`grep "bin_" /etc/passwd | /bin/awk -F: -v user="$user" '$1 == user'`
### echo $block_login
if [[ -n $block_login ]]; then
echo "The user $user's account is locked."
echo "Please check https://tas.tacc.utexas.edu/TACCAdministration/ for more details."
exit
fi
###Old checking rules:
###block_normal=`awk '/ALL = /,/ALL = /' /etc/slurm/tacc_filter_options | grep $user`
###block_large=`grep "^largemem" /etc/slurm/tacc_filter_options | grep $user`
##Whether the user is blocked from general submission:
block_normal=`awk '/ALL *= /,/ALL *= /' $block_list | awk '{gsub(/ /, "", $0); print substr($0,7,length($0)-7)}' | awk -v user="$user" 'BEGIN {FS=" |!"}; {for (i=1; i<=NF; i++) if ($i == user) {print $0}}'`
##whether the user is blocked from largemem queue submission:
block_large=`awk '($1=="largemem")' $block_list | awk '{gsub(/ /, "", $0);print substr($0,12, length($0)-12)}' | awk -v user="$user" 'BEGIN {FS="!!"}; {for (i=1; i<=NF; i++) if ($i == user) {print $0}}'`
##whether the user is blocked from mic queue submission
block_mic=`awk '($1=="normal-mic" || $1=="normal-2mic")' $block_list | awk '{gsub(/ /, "", $0); print substr($0,14, length($0)-14)}' | awk -v user="$user" 'BEGIN {FS="!!"}; {for (i=1; i<=NF; i++) if ($i == user) {print $0}}'`
if [[ -n $block_large ]]; then
echo "$user is not allowed to submit largemem jobs on the system"
echo "Possible block reason from System Administrators:"
awk '/# Disabled/,/ALL *= /' $block_list | grep $user
fi
if [[ -n $block_normal ]]; then
echo "$user is not allowed to submit jobs on the system."
echo "Possible block reason from System Administrators:"
awk '/# Disabled/,/ALL *= /' $block_list | grep $user | sed '$d'
fi
if [[ -n $block_mic ]]; then
echo "$user is not allowed to submit Xeon-Phi (MIC) jobs on the system."
echo "Possible block reason from System Administrators:"
awk '/# Disabled/,/ALL *= /' $block_list | grep $user | sed '$d'
fi
#No problem at all:
if [[ -z $block_normal && -z $block_large && -z $block_mic ]]; then
echo "$user is NOT blocked by the system administrators at this time."
fi
exit