[root@prometheus-linkdoc application]# cat test.sh
#!/bin/bash Alert_gateway_process_num=$(ps -ef |grep alert_gateway|grep -v grep|grep -v SCREEN|wc -l) Alertmanager_process_num=$(ps -ef |grep alertmanager|grep -v grep |grep -v alertmanager_start.sh|wc -l) Blackbox_exporter_process_num=$(ps -ef |grep blackbox_exporter|grep -v grep|wc -l) Prometheus_process_num=$(ps -ef |grep prometheus|grep -v grep |grep -v prometheus_start.sh|wc -l) Dingding_alert(){ Dingding_Uri="https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxdae8e9b02bedb343fb422b9350" curl $Dingding_Uri -H 'Content-Type: application/json' -d " { \"actionCard\": { \"title\": \"监控进程掉线\", \"text\": \"$1 进程掉线 请及时查看\", \"hideAvatar\": \"0\", \"btnOrientation\": \"0\", \"btns\": [ { \"title\": \"$1\", \"actionURL\": \"\" } ] }, \"msgtype\": \"actionCard\" }" } if [ $Alert_gateway_process_num -eq 0 ] then Dingding_alert alert_gateway fi if [ $Alertmanager_process_num -eq 0 ] then Dingding_alert alertmanager fi if [ $Blackbox_exporter_process_num -eq 0 ] then Dingding_alert blackbox_exporter fi if [ $Prometheus_process_num -eq 0 ] then Dingding_alert prometheus fi