3 # lc_net - script for Lustre cluster network verification
5 ###############################################################################
11 Usage: `basename $0` [options] <csv file>
14 -a select all the nodes from the csv file to operate on
15 -w hostname,hostname,...
16 select the specified list of nodes (separated by commas)
17 -x hostname,hostname,...
18 exclude the specified list of nodes (separated by commas)
20 csv file a spreadsheet that contains configuration parameters
21 (separated by commas) for each target in a Lustre cl-
22 uster, the first field of each line is the host name
29 # Get the library of functions
30 . @scriptlibdir@/lc_common
33 # Get and check the positional parameters
34 while getopts "aw:x:v" OPTION; do
37 [ -z "${SPECIFIED_NODELIST}" ] && [ -z "${EXCLUDED_NODELIST}" ]\
42 SPECIFIED_NODELIST=$OPTARG
46 EXCLUDED_NODELIST=$OPTARG
56 # Toss out the parameters we've already processed
57 shift `expr $OPTIND - 1`
59 # Here we expect the csv file
61 echo >&2 $"`basename $0`: Missing csv file!"
68 declare -a HOST_IPADDRS
70 # Get the hosts to be operated on
74 # Initialize the HOST_NAMES array
77 # Get the list of nodes to be operated on
78 NODES_TO_USE=$(get_nodelist)
79 [ ${PIPESTATUS[0]} -ne 0 ] && echo >&2 "${NODES_TO_USE}" && return 1
82 if [ -z "${NODES_TO_USE}" ]; then
83 echo "`basename $0`: There are no hosts to be operated on."\
84 "Check the node selection options (-a, -w or -x)."
88 # Load the hostnames in the nodelist into the array
89 HOST_NAMES=( $(echo ${NODES_TO_USE//,/ }) )
95 # Check whether host $host_name is reachable.
96 # If it is, then return the IP address of this host.
102 if [ -z "${host_name}" ]; then
103 echo "`basename $0`: ping_host() error: Missing hostname!"
108 ret_str=$(ping -c1 ${host_name} 2>&1)
109 if [ ${PIPESTATUS[0]} -ne 0 ]; then
110 if [ -n "${ret_str}" ]; then
111 echo "`basename $0`: ping_host() error: ${ret_str}!"
113 echo "`basename $0`: ping_host() error:"\
114 "Host ${host_name} does not respond to ping!"
120 ip_addr=`echo "${ret_str}" | head -1 | awk '{print $3}' | \
121 sed -e 's/^(//' -e 's/)$//'`
128 # Check the network connectivity between local host and ${HOST_NAMES[index]}.
132 # Check whether ${HOST_NAMES[i]} is reachable
133 # and get the IP address of this host from ping
134 HOST_IPADDRS[i]=$(ping_host ${HOST_NAMES[i]})
135 if [ ${PIPESTATUS[0]} -ne 0 ]; then
136 echo >&2 "${HOST_IPADDRS[i]}"
144 # Check whether ${HOST_NAMES[index]} can resolve its own name and whether
145 # this host agrees with the local host about what its name is resolved to.
149 local ip_addr= # the IP address got from remote ping
151 # Execute remote command to check whether ${HOST_NAMES[i]}
152 # can resolve its own name
153 cmd="ping -c1 ${HOST_NAMES[i]} 2>&1"
154 ret_str=$(${REMOTE} ${HOST_NAMES[i]} "${cmd}" 2>&1)
155 if [ ${PIPESTATUS[0]} -ne 0 -a -n "${ret_str}" ]; then
156 echo >&2 "`basename $0`: remote_check() error:"\
157 "remote to ${HOST_NAMES[i]} error: ${ret_str}!"
161 if [ -z "${ret_str}" ]; then
162 echo >&2 "`basename $0`: remote_check() error:"\
163 "No results from ${HOST_NAMES[i]}! Check the network"\
164 "connectivity between local host and ${HOST_NAMES[i]}!"
168 # Get the IP address of ${HOST_NAMES[i]} from its own ping
170 ip_addr=`echo "${ret_str}" | head -1 | awk '{print $4}'`
172 ip_addr=`echo "${ret_str}" | head -1 | awk '{print $3}'`
174 ip_addr=`echo "${ip_addr}" | sed -e 's/^(//' -e 's/)$//'`
176 # Compare IP addresses
177 # Check whether ${HOST_NAMES[i]} agrees with the local host
178 # about what its name is resolved to.
179 if [ "${ip_addr}" != "${HOST_IPADDRS[i]}" ]; then
180 echo >&2 "`basename $0`: remote_check() error:"\
181 "Local host resolves ${HOST_NAMES[i]} to IP address"\
182 "\"${HOST_IPADDRS[i]}\", while its own resolution is"\
183 "\"${ip_addr}\". They are not the same!"
191 # Verify name resolution and network connectivity of the Lustre cluster
195 # Initialize the HOST_IPADDRS array
198 # Get all the host names to be operated on
199 ! get_hostnames && return 1
201 # Check the network connectivity between local host
202 # and other cluster nodes
203 for ((i = 0; i < ${#HOST_NAMES[@]}; i++)); do
204 [ "${HOST_NAMES[i]}" = "`hostname`" ] && continue
206 verbose_output "Verifying network connectivity between"\
207 "\"`hostname`\" and \"${HOST_NAMES[i]}\"..."
208 ! local_check $i && return 1
209 ! remote_check $i && return 1
217 if ! check_file ${CSV_FILE}; then
221 # Cluster network verification
222 if ! network_verify; then