监控Nginx负载均衡器脚本

1.编写脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
vim nginx_pid.sh
#!/bin/bash
while  :
do
nginxpid=`ps -C nginx --no-header | wc -l`
if [ $nginxpid -eq 0 ];then
/usr/local/nginx/sbin/nginx
sleep 5
  if [ $nginxpid -eq 0 ];then
  /etc/init.d/keepalived stop
  fi
fi
sleep 5
done
原文地址:https://www.cnblogs.com/timssd/p/4333051.html