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
本文出自 “杜海强” 博客,转载请与作者联系!
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
本文出自 “杜海强” 博客,转载请与作者联系!
相关文章推荐
- /etc/init.d/nginx
- nginx直接访问html的配置
- LNMP环境编译安装centos5x/nginx_1.4/mysql_5.6/php_5.4
- Nginx之location详解
- nginx ssl 部分加密
- nginx负载均衡配置
- nginx代理与负载均衡配置
- Nginx 错误汇总
- Nginx学习及实践
- NGINX引入线程池 性能提升9倍
- 手把手教你认识并搭建Nginx
- nginx源码分析—模块及其初始化(二)
- 解决nginx + lua 上传文件问题
- nginx安装和配置
- Linux环境下Nginx安装及Ubuntu Server 15.0.4尝试安装Nginx
- nginx 配置 性能优化
- nginx源码分析—队列结构ngx_queue_t
- nginx源码分析—链表结构ngx_list_t
- nginx web server 不能正确解析css问题
- nginx 正则表达式匹配入门篇 .