ZABBIX配置钉钉机器报警

概述

zabbix报警方式有多种,下面分享一下基于dingding报警的配置方式

二、过程

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、效果展示

 

原文地址:https://www.cnblogs.com/lkj371/p/12867900.html