-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfmrilab_check_NFS.sh
executable file
·159 lines (123 loc) · 2.67 KB
/
fmrilab_check_NFS.sh
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/bin/bash
# This script checks if the mount points are truly nfs by traversing /misc and checking each subfolder.
# It also makes a check to see if a test file can be read, the ultimate test for file system integrity.
# such a file is in /misc/HOST/.testDir/.testFile and contains only the word "OK" (it is cat to prove that nfs is working)
# (if installing a new hard drive, make sure you create that file!)
verbose=0
for arg in "$@"
do
case "$arg" in
-V)
verbose=1
;;
esac
i=$[$i+1]
done
reset="\e[0m"
colorerror="\e[38;5;202m"
colorinfo="\e[33m"
colorOK="\e[32m"
tmpFile=/tmp/check_NFS_$$.txt
Errors=""
fmrilab_misc_file=/home/inb/soporte/configs/fmrilab_auto.misc
grep datos $fmrilab_misc_file | \
grep --invert-match "#" | \
awk '{OFS = ";"} {print $1}' | \
uniq | sort > $tmpFile
# first we check /misc
d=1
while read h
do
if [ $verbose -eq 1 ]
then
printf "${colorinfo} ${h}: $reset"
fi
if [[ "$h" == "lost+found" ]]
then
continue
fi
#if [[ $h == `uname -n`* ]]
#then
# continue
# fi
whiteList=`cat /home/inb/soporte/inb_cluster_whiteList.txt`
isWhite=0
for w in $whiteList
do
if [[ "${h//[0-9]/}" == "$w" ]]
then
if [ $verbose -eq 1 ]
then
printf " %s\n" "W"
else
printf "%s" "W"
fi
isWhite=1
fi
done
if [ $isWhite -eq 1 ]
then
continue
fi
d=$(($d+1))
mPoint=/misc/$h
#fSystem=`stat -f -L -c %T $mPoint`
#if [[ ! "$fSystem" == "nfs" ]]
#then
# Errors="$Errors $mPoint"
#fi
testFile=/misc/${h}/.testDir/.testFile
timed_out=0
tout=3
timeout $tout ls $mPoint > /dev/null
if [[ $? == 124 ]]
then
#echo "[ERROR] $h is taking longer than $tout seconds to respond."
timed_out=1
if [ $verbose -eq 0 ]
then
printf "%s" "T"
else
printf "${colorerror} TIMED_OUT\n$reset"
fi
Errors="$Errors ( $mPoint timed out ),"
continue
fi
if [[ ! -f $testFile ]]
then
Errors="$Errors ( cannot find $testFile ),"
if [ $verbose -eq 0 ]
then
printf "%s" "E"
else
printf "${colorerror} ERROR\n$reset"
fi
else
if [ $verbose -eq 0 ]
then
printf "%s" "."
else
printf "${colorOK} OK\n$reset"
fi
fi
done < $tmpFile
# and now we check /home/inb, unless in hahn
if [[ ! `uname -n` == "hahn" ]]
then
mPoint=/home/inb
fSystem=`stat -f -L -c %T $mPoint`
if [[ ! "$fSystem" == "nfs" ]]
then
Errors="$Errors $mPoint"
fi
fi
# and spit out some results
if [ ! -z "$Errors" ]
then
printf "\n THERE ARE MOUNTING ERRORS IN $HOSTNAME:\n"
echo "$Errors" | sed 's/,/\n/g'
else
cat $testFile
#echo -e "\e[32m OK \e[0m"
fi
rm $tmpFile