zabbix启用企业微信告警的脚本

1,路径是在/usr/lib/zabbix/alertscripts

文件名随意设置,我这里设置的是weixin.py
我的python版本是 python2.7.5的

zabbix版本是5.0的;
脚本内容如下 直接照抄就可以了。亲测有效,目前有在用

#!/usr/bin/python2
# coding:utf-8
import urllib
import urllib2
import json
import sys

reload(sys)
sys.setdefaultencoding('utf-8')


def gettoken(corpid,corpsecret):
    gettoken_url = 'https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=' + corpid + '&corpsecret=' + corpsecret
    #print  gettoken_url
    try:
        token_file = urllib2.urlopen(gettoken_url)
    except urllib2.HTTPError as e:
        print e.code
        print e.read().

猜你喜欢

转载自blog.csdn.net/Lcongming/article/details/122706184