在应用层面上,会跑很多服务,那么监控系统服务状态就变得很必要了
#!/bin/bash pid() { ps ax | grep "APPLICATION" | grep -v grep >/dev/null 2>&1 if [ $? -eq 0 ];then echo 1 else echo 0 fi } PID=`pid` post() { netstat -ntpl | grep POST-NUMBER >/dev/null 2>&1 if [ $? -eq 0 ];then echo 1 else echo 0 fi } POST=`post` stat() { ps ax | grep "APPLICATION" | grep -v grep | awk ‘{print $3}‘ >/dev/null 2>&1 if [ $? != "SZ" -o $? != "Sz" -o $? != "Zz" ];then echo 1 else echo 0 fi } STAT=`stat` if [ $PID = 1 -a $POST = 1 -a $STAT = 1 ];then echo 0 else echo 1 fi
同事满足3个条件 证明这个服务运行状态是正常的,返回0 任意个一条件不符合,都返回1
时间: 2024-10-09 13:59:16