您的位置:首页 > 运维架构 > Nginx

keepalive监控nginx

2015-10-30 19:07 676 查看
#!/bin/bash
while :
do
###process count
NGINX_COUNT=`ps -C nginx --no-header|wc -l`
KEEPALIVED_COUNT=`ps -C keepalived --no-header|wc -l`
#if [ $NGINX_COUNT -eq 0 ] && [ $KEEPALIVED_COUNT -eq 0 ];then
# /etc/init.d/nginx restart && /etc/init.d/keepalived restart
if [ $NGINX_COUNT -eq 0 ] && [ $KEEPALIVED_COUNT -gt 0 ];then
/etc/init.d/nginx restart
sleep 3
NGINX_COUNT=`ps -C nginx --no-header|wc -l`
[ $NGINX_COUNT -eq 0 ] && /etc/init.d/keepalived stop
elif [ $NGINX_COUNT -gt 0 ] && [ $KEEPALIVED_COUNT -eq 0 ];then
/etc/init.d/keepalived start
fi
sleep 5
done

本文出自 “杜海强” 博客,转载请与作者联系!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: