經過shell腳本 curl調用釘釘接口將報警信息推到釘釘聊天框shell
[root@prometheus-linkdoc application]# cat test.shjson
#!/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