ZABBIX配置钉钉机器报警
概述
二、过程
1、修改zabbix-server主配置文件
[root@localhost alertscripts]# cat /etc/zabbix/zabbix_server.conf |grep AlertScriptsPath ### Option: AlertScriptsPath # AlertScriptsPath=${datadir}/zabbix/alertscripts AlertScriptsPath=/usr/lib/zabbix/alertscripts
2、在AlertScriptsPath所在目录路径下放置dingding脚本
[root@localhost alertscripts]# cat dingding.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后跟告警机器人的webhook api_url = "************" def msg(text): json_text= { "msgtype": "text", "text": { "content": text }, "at": { "atMobiles": [ "**********" ], "isAtAll": False } } print(requests.post(api_url,json.dumps(json_text),headers=headers).content) if __name__ == '__main__': text = sys.argv[1] msg(text)
3、效果展示
喜欢请赞赏一下啦^_^
微信赞赏
支付宝赞赏