shell脚本写一个物理服务器集群巡检脚本
时间: 2023-05-11 22:06:15 浏览: 171
shell巡检脚本
可以使用以下脚本来进行物理服务器集群巡检:
```
#!/bin/bash
# Define the list of servers to check
servers=("server1" "server2" "server3")
# Loop through the servers and check their status
for server in "${servers[@]}"
do
echo "Checking server $server..."
ping -c 1 $server > /dev/null
if [ $? -eq 0 ]
then
echo "Server $server is up and running."
else
echo "Server $server is down."
fi
done
```
这个脚本会循环遍历服务器列表,并使用 ping 命令检查每个服务器的状态。如果服务器正常运行,脚本会输出 "Server [server name] is up and running.",否则会输出 "Server [server name] is down."。
阅读全文