zoukankan      html  css  js  c++  java
  • zabbix 配合钉钉群机器人(webhook) 报警

    首先建钉钉群,添加一个自定义机器人拿到webhook

    zabbix添加一个报警媒介

     搞一个shell脚本来启动Python脚本(直接用zabbix调Python脚本不行,不知道什么原因)

    vim dingding.sh
    echo "$1" > /tmp/dingding.log
    python /etc/zabbix/alertscripts/dingding.py "$1"
    #!/usr/bin/env python
    #coding: utf-8
    import json,urllib2,sys
    
    def dingding(message):
        url = "https://oapi.dingtalk.com/robot/send?access_token=xxxx"
        header = {
            "Content-Type": "application/json",
            "charset": "utf-8"
            }
        data = {
             "msgtype": "text",
                "text": {
                    "content": message
                }
            }
        sendData = json.dumps(data)
        request = urllib2.Request(url,data = sendData,headers = header)
        urlopen = urllib2.urlopen(request)
        return urlopen.read()
    def main():
         message = sys.argv[1]
         dingding(message)
    if __name__ == "__main__":
        main()
  • 相关阅读:
    IO
    mouseover,mouseout和mouseenter,mouseleave
    【译】addEventListener 第二个参数
    Git 常用命令
    我对Backbone中url属性的理解
    小失误引起大失败
    收集各大网站的登录页面
    随笔2
    随笔1
    创建数据库
  • 原文地址:https://www.cnblogs.com/37yan/p/7602580.html
Copyright © 2011-2022 走看看