centos7-监控keepalived是否启动的shell脚本

监控keepalived的shell脚本参考

#!/bin/bash
while true
do
   counter=$(netstat -na|grep "LISTEN"|grep "3306"|wc -l)
   if [ "${counter}" -eq 0 ]; then
            #echo "no mysql process";
            continue;
    else
        counter2=$(netstat -na|grep "LISTEN"|grep "/usr/sbin/keepalived"|wc -l)
        if [ "${counter2}" -eq 0 ]; then
	    #echo "mysql process";
            systemctl start keepalived;
            continue;
        else
            #echo "continue"; 
            continue;
        fi
    fi
done 


内容解释

  1. wc 统计文件中有多少行、多少单词、多少字符

-l :有多少行
-w :有多少单词
-m :多少字符

上一篇:执行hadoop fs -ls时出现错误RuntimeException: core-site.xml not found


下一篇:文件操作类命令