prometheusコンポーネントプロセス自体監視
1583 ワード
shellスクリプトcurlで釘インタフェースを呼び出してアラーム情報を釘チャットボックスにプッシュ
[root@prometheus-linkdoc application]# cat test.sh
[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