Rabbitmq队列监控-发送钉钉消息
function DingdingRobot(){
curl ‘https://oapi.dingtalk.com/robot/send?access_token=xxxxxx’ -H ‘Content-Type: application/json’ \
-d ‘
{“msgtype”: “text”,
“text”: {
“content”:”监控报警:'”$1″‘”
}
}’
}
Alarm=$(rabbitmqctl list_queues |grep -v ‘Listing queues …’ | grep -v Timeout |awk ‘{if($2>=10)print $0}’|grep -v ‘name’)
if [[ $Alarm != “” ]]
then
DingdingRobot “消息队列堆积数量>=10 – [$Alarm]”
fi
exit 0
定时任务:
将上面的脚本写入linux文件中,并添加执行权限,然后在/etc/crontab 里面添加任务执行周期