zoukankan      html  css  js  c++  java
  • 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、效果展示

     

  • 相关阅读:
    idea修改代码没法实时编译终极解决方案
    linux 安装 hadoop
    linux克隆虚拟机后需要修改的点
    多线程第一篇
    windows搭建ftp环境
    第8章PostGIS参考
    postgis 简单应用
    linux 安装postgresql
    复杂度分析(下)
    复杂度分析(上)
  • 原文地址:https://www.cnblogs.com/lkj371/p/12867900.html
Copyright © 2011-2022 走看看