In order to check the network connection status between the daq01 and the blade server,
1. Use the output rule of ping command, if can ping pass, will output 0% packet loss value; If you cannot ping the pass, the 0% packet loss is not output
2. If the ping command output 0% packet loss successful execution, the network connection is OK, otherwise the network connection is not
3. && in Shell scripts | | For use, refer to 20360107
Command1 && Command2
Indicates: If Command1 execution succeeds && executes Command2
Command1 | | Command2
Indicates: if Command1 execution Fails | | Then execute Command2
4. The hostname of the blade server can be grep from the/etc/hosts file
Script content:
1 #!/bin/bash2 3 host= ' grep cmm03node/etc/hosts |awk ' {print $} '4 5 for line in $host 6 Do7 ping-c 3 $l ine | Grep-q "0% packet loss" && echo "$line OK" | | echo "$line fail" 8 Done
The results are as follows:
Ping. SH cmm03node01 okcmm03node02 okcmm03node03 okcmm03node04 okcmm03node05 okcmm03node06 OKcmm03node07 OKcmm03node08 Okcmm03node09 okcmm03node10 okcmm03node11 okcmm03node12 okcmm03node13 okcmm03node14 OK
Description The network between the DAQ01 and the blade server is normal!
Using shell scripting to ping Check network connectivity between the blade server and the primary server