3 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
6 # lc_net - script for Lustre cluster network verification
8 ###############################################################################
14 Usage: `basename $0` [options] <csv file>
17 -a select all the nodes from the csv file to operate on
18 -w hostname,hostname,...
19 select the specified list of nodes (separated by commas)
20 -x hostname,hostname,...
21 exclude the specified list of nodes (separated by commas)
23 csv file a spreadsheet that contains configuration parameters
24 (separated by commas) for each target in a Lustre cl-
25 uster, the first field of each line is the host name
32 # Get the library of functions
33 . @scriptlibdir@/lc_common
36 # Get and check the positional parameters
37 while getopts "aw:x:v" OPTION; do
40 [ -z "${SPECIFIED_NODELIST}" ] && [ -z "${EXCLUDED_NODELIST}" ]\
45 SPECIFIED_NODELIST=$OPTARG
49 EXCLUDED_NODELIST=$OPTARG
59 # Toss out the parameters we've already processed
60 shift `expr $OPTIND - 1`
62 # Here we expect the csv file
64 error_output "Missing csv file!"
71 declare -a HOST_IPADDRS
73 # Get the hosts to be operated on
77 # Initialize the HOST_NAMES array
80 # Get the list of nodes to be operated on
81 NODES_TO_USE=$(get_nodelist)
82 [ ${PIPESTATUS[0]} -ne 0 ] && error_output "${NODES_TO_USE}" && return 1
85 if [ -z "${NODES_TO_USE}" ]; then
86 echo "`basename $0`: There are no hosts to be operated on."\
87 "Check the node selection options (-a, -w or -x)."
91 # Load the hostnames in the nodelist into the array
92 HOST_NAMES=( $(echo ${NODES_TO_USE//,/ }) )
98 # Check whether host $host_name is reachable.
99 # If it is, then return the IP address of this host.
105 if [ -z "${host_name}" ]; then
106 echo "`basename $0`: ping_host() error: Missing hostname!"
111 ret_str=$(ping -c1 ${host_name} 2>&1)
112 if [ ${PIPESTATUS[0]} -ne 0 ]; then
113 if [ -n "${ret_str}" ]; then
114 echo "`basename $0`: ping_host() error: ${ret_str}!"
116 echo "`basename $0`: ping_host() error:"\
117 "Host ${host_name} does not respond to ping!"
123 ip_addr=`echo "${ret_str}" | head -1 | awk '{print $3}' | \
124 sed -e 's/^(//' -e 's/)$//'`
131 # Check the network connectivity between local host and ${HOST_NAMES[index]}.
135 # Check whether ${HOST_NAMES[i]} is reachable
136 # and get the IP address of this host from ping
137 HOST_IPADDRS[i]=$(ping_host ${HOST_NAMES[i]})
138 if [ ${PIPESTATUS[0]} -ne 0 ]; then
139 error_output "${HOST_IPADDRS[i]}"
147 # Check whether ${HOST_NAMES[index]} can resolve its own name and whether
148 # this host agrees with the local host about what its name is resolved to.
152 local ip_addr= # the IP address got from remote ping
154 # Execute remote command to check whether ${HOST_NAMES[i]}
155 # can resolve its own name
156 cmd="ping -c1 ${HOST_NAMES[i]} 2>&1"
157 ret_str=$(${REMOTE} ${HOST_NAMES[i]} "${cmd}" 2>&1)
158 if [ ${PIPESTATUS[0]} -ne 0 -a -n "${ret_str}" ]; then
159 error_output "remote_check():"\
160 "remote to ${HOST_NAMES[i]} error: ${ret_str}!"
164 if [ -z "${ret_str}" ]; then
165 error_output "remote_check():"\
166 "No results from ${HOST_NAMES[i]}! Check the network"\
167 "connectivity between local host and ${HOST_NAMES[i]}!"
171 # Get the IP address of ${HOST_NAMES[i]} from its own ping
172 ip_pattern="[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"
173 ip_addr=`echo "${ret_str}" | egrep -m 1 -o "${ip_pattern}"`
175 # Compare IP addresses
176 # Check whether ${HOST_NAMES[i]} agrees with the local host
177 # about what its name is resolved to.
178 if [ "${ip_addr}" != "${HOST_IPADDRS[i]}" ]; then
179 error_output "remote_check():"\
180 "Local host resolves ${HOST_NAMES[i]} to IP address"\
181 "\"${HOST_IPADDRS[i]}\", while its own resolution is"\
182 "\"${ip_addr}\". They are not the same!"
190 # Verify name resolution and network connectivity of the Lustre cluster
194 # Initialize the HOST_IPADDRS array
197 # Get all the host names to be operated on
198 ! get_hostnames && return 1
200 # Check the network connectivity between local host
201 # and other cluster nodes
202 for ((i = 0; i < ${#HOST_NAMES[@]}; i++)); do
203 [ "${HOST_NAMES[i]}" = "`hostname`" ] && continue
205 verbose_output "Verifying network connectivity between"\
206 "\"`hostname`\" and \"${HOST_NAMES[i]}\"..."
207 ! local_check $i && return 1
208 ! remote_check $i && return 1
216 if ! check_file ${CSV_FILE}; then
220 # Cluster network verification
221 if ! network_verify; then