码迷,mamicode.com
首页 > 其他好文 > 详细

keepalive监控nginx

时间:2015-10-31 01:49:32      阅读:256      评论:0      收藏:0      [点我收藏+]

标签:process   监控   sleep   

#!/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

本文出自 “杜海强” 博客,转载请与作者联系!

keepalive监控nginx

标签:process   监控   sleep   

原文地址:http://dulinux.blog.51cto.com/10803129/1708172

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!