一、添加钉钉群机器人,获取webhook地址
1、
2、
3、
4、
5、
二、配置报警触发脚本
[root@zhangxin alertscripts]# cat /usr/lib/zabbix/alertscripts/dingding1.py #!/usr/bin/python # -*- coding: utf-8 -*- import requests import json import sys import os headers = {'Content-Type': 'application/json;charset=utf-8'} api_url = "https://oapi.dingtalk.com/robot/send?access_token=d3806ed133584fefdec932eca9fcfc41fd4ca0e452075a9680927e676e0b4d22" #钉钉的Webhook def msg(text): json_text= { "msgtype": "text", "at": { "atMobiles": [ "153xxxxxxxx" #制定@某个人 ], "isAtAll": False }, "text": { "content": text } } print requests.post(api_url,json.dumps(json_text),headers=headers).content if __name__ == '__main__': text = sys.argv[1] msg(text) [root@zhangxin alertscripts]#