Nginx监控脚本

来源:互联网 发布:淘宝客一键复制 编辑:程序博客网 时间:2024/06/05 21:04

网上找了好多材料,发现更多的nginx+keepalived的监控脚本都是一个例子

#!/bin/bashnginxtest='ps -C nginx --no-header | wc -l'if [ $nginxtest -eq 0 ]; then       /usr/local/nginx/conf/nginx       sleep 5       nginxtest='ps -C nginx --no-header |wc -l'       echo $nginxtest       if [ $nginxtest -eq 0 ]; then            /etc/init.d/keepalived stop       fifisleep 5


运行之后报错。

./nginx_pid.sh: line 4: [: too many arguments

至今未解决,知道上面错误的请指正


改善后的脚本

#!/bin/bashps -C nginx --no-headerif [ $? -ne 0 ]; then        /usr/local/nginx/sbin/nginx        sleep 5        ps -C nginx --no-header        if [ $? -ne 0 ]; then                /etc/init.d/keepalived stop        fifisleep 5



0 0