zabbix实现钉钉告警
作者:互联网
创建钉钉webhook可以参考钉钉官网文档:https://ding-doc.dingtalk.com/doc#/serverapi2/qf2nxq
本文为通过shell脚本实现钉钉告警,脚本如下
[root@yangzhao alertscripts]# cat /usr/lib/zabbix/alertscripts/dingding.sh
#!/bin/bash
to=$1
subject=$2
text=$3
#此处的 xxxxx 就是刚刚复制钉钉webhook的 api 接口地址
#“业务报警”为创建webhook时候的关键字
curl -i -X POST \
'https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxx' \
-H 'Content-type':'application/json' \
-d '
{
"msgtype": "text",
"text": {
"content": "'业务报警:''"$text"'"
},
"at":{
"atMobiles":[
"'"$1"'"
],
"isAtAll":false
}
}'
测试命令:
bash /usr/lib/zabbix/alertscripts/dingding.sh Shell脚本测试
使用单独命令测试
curl 'https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxx' -H 'Content-Type: application/json' -d '{"msgtype": "text","text": {"content": "业务报警,Shell 脚本测试"}}'
测试结果
标签:dingtalk,实现,text,webhook,alertscripts,zabbix,https,告警 来源: https://blog.csdn.net/ZuoGaoGaoSuDiDi/article/details/110522249