#磁盘告警token
token1=ae417ee7e39bb6457065903a6f41c1ec53c566820d08d2dae566da1fecbbxxxx
#针对不同系统,命令不同路径的解决方法
date_com=`/usr/bin/which date`
#获取主机名
system_hostname=$(hostname | awk '{print $1}')
#获取ip
system_ip=`/sbin/ifconfig |grep -v 172.17.0.1 |awk '/inet / && !($2 ~ /^127/){print $2}'|grep -oE '[0-9]+\..*$'|head -n1`
#获取当前系统时间
date=`${date_com} +%Y/%m/%d\ %H:%M`
list=`supervisorctl status|awk '{print $1}'|awk -F: '{print $1}'|sort -u|grep -v update-sale-stats`
for i in $list
do
PROCESS=`ps -ef |grep $i |grep -v grep |wc -l`
if [ ! -n "PROCESS" ]
then
break
else
if [ $PROCESS = 0 ]
then
/usr/bin/curl 'https://oapi.dingtalk.com/robot/send?access_token='$token1'' \
-H 'Content-Type: application/json' \
-d "{'msgtype': 'text','text': {'content': '队列告警:\n队列名称:$i \n状态:进程不存在\n主机名:$system_hostname \nIP地址:$system_ip \n当前时间:$date'}}"
fi
fi
done