第7章 钉钉告警
1.编写钉钉脚本
https://open.dingtalk.com/document/orgapp/custom-robots-send-group-messages
注意:要放在zabbix_server指定的脚本路径
[root@m-61 /usr/lib/zabbix/alertscripts]# cat ding.sh
#!/bin/bash
token='8c44c06ab3e60136de9166143c62faf39af057cddff5468acc298bbbc18c532a'
user=$1
title=$2
message=$3
curl -X POST "https://oapi.dingtalk.com/robot/send?access_token=$token" -H 'Content-Type: application/json' -d '
{
"at":{
"isAtAll":"false",
"atMobiles":["'"$user"'"]
},
"text":{
"content":"'"$title\n$message"'"
},
"msgtype":"text"
}' >> /tmp/dingding.log 2>&1
echo -e "\n报警时间:$(date +%F-%H:%M)\n报警标题:${title}\n报警内容:${message}" >> /tmp/dingding.log
[root@m-61 /usr/lib/zabbix/alertscripts]# chmod +x ding.sh