实现kafka消息队列服务崩溃无反应的及时报警
编写报警服务脚本
#!/bin/bash
function checkKafka {
process_name=$1
pid=`ps -Aww -o pid,command | grep -i "[j]ava" | grep ${process_name} | awk '{print $1}'`
if [ -z $pid ];
then
#pushToken需要登录比特信(bit.dayutec.cn)获取
curlTxt=`curl -ik -X POST --header 'Content-Type: application/json' -d '{"title": "比特信","content": "Kafka应用进程崩溃,请马上排查并恢复服务"}' "https://push.dayutec.cn/bit/send?pushToken=6EA9B77711**********7236C11"`
echo "$curlTxt"
else
echo "${process_name}服务正常"
fi
}
function checkServer {
checkKafka Kafka
}
checkServer
设定脚本执行定时任务
crontab -e
#1分钟检查一次
*/1 * * * * sh ~/server_check.sh >> /tmp/server_check.log