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

     

  • 相关阅读:
    Druid.io系列(三): Druid集群节点
    Druid.io系列(二):基本概念与架构
    Druid.io系列(一):简介
    am335x backlight
    imx6 fec分析
    imx6 ar8031 千兆网卡不能用
    imx6 spi分析
    imx6 i2c分析
    imx6 uart分析
    imx6 gpio分析
  • 原文地址:https://www.cnblogs.com/lkj371/p/12867900.html
Copyright © 2011-2022 走看看