作者:拍友2502914573 | 来源:互联网 | 2023-07-31 20:52
背景 公司一般做业务监控都是采用实时任务的方式,实时任务的可用性就更加需要保障了。
监控脚本 #!/bin/bash mysql -hhdh06.c.p.xyidc -uuser -ppasswd < stream.sql > a.txt yarn application -list | grep stream > b.txtsed -n &#39;2,$p &#39; a.txt| while read linedo name&#61; &#96; sed -n /$line/p b.txt &#96; if [ "$name " !&#61; "" ] ; then appid&#61; &#96; sed -n /$line/p b.txt | awk &#39;{print $1 }&#39; &#96; url&#61; &#96; sed -n /$line/p b.txt | awk &#39;{print $9 }&#39; &#96; echo $line -- $appid $( curl -L --connect-timeout 20 ${ url} /streaming > c.txt) $( sed -i &#39;s/} ) /a/g&#39; c.txt)active&#61;&#96;sed -n &#39; /Active Batches/p&#39; c.txt | awk -F"[()]" &#39;{print $2 }&#39; &#96;echo active:$active if [ -z $active ] ; then echo 实时任务${line} 运行异常,任务id:${appid} ,不能获取driver运行状态,快检查driver日志! curl "http://xxxx:8080/alarm/sendSms.do?mobile&#61;15158137***&type&#61;0&producer&#61;CDH&body&#61;实时任务告警&#xff0c;实时任务${line} 运行异常,任务id:${appid} ,不能获取driver运行状态,快检查driver日志!" elif [ $active -gt $1 ] ; then echo 实时任务${line} 运行出现堆积,任务id:${appid} ,当前堆积${active} 批次! curl "http://xxxx:8080/alarm/sendSms.do?mobile&#61;1515813***&type&#61;0&producer&#61;CDH&body&#61;实时任务告警&#xff0c;实时任务${line} 运行出现堆积,任务id:${appid} ,当前堆积${active} 批次!" else echo $appid 任务运行正常&#xff01; fi else echo 实时任务告警&#xff0c;未检测到运行任务&#xff0c;实时任务${line} 已停止运行&#xff01;请检查任务日志&#xff01; curl "http://xxxx:8080/alarm/sendSms.do?mobile&#61;1515813***&type&#61;0&producer&#61;CDH&body&#61;实时任务告警&#xff0c;未检测到运行任务&#xff0c;实时任务${line} 已停止运行&#xff01;请检查任务日志&#xff01;" fi done