1、企业微信管理员登录后台查看企业corpid、要发送告警的部门id,记录下来
2、创建应用
3、点击创建的应用,进去查看记录这两个值:AgentId、Secret
4、在zabbix-server端编写脚本
#!/usr/bin/env python
# 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
try:
token_file = urllib2.urlopen(gettoken_url)
except urllib2.HTTPError as e:
print e.code
print e.read().decode("utf-8")
sys.exit()
token_data = token_file.read().decode('utf-8')
token_json = json.loads(token_data)
token_json.keys()
token = token_json['access_token']
return