Home > other >  Enterprise WeChat receive less than zabbix alarm content
Enterprise WeChat receive less than zabbix alarm content

Time:11-02

Enterprise WeChat receives the zabbix alarm information title after click more  configuration actions below  alarm script parameters of the medium as follows
Script code
#! The/usr/bin/python
# - * - coding: utf-8 - * -
# zabbix notification confirmation script
# python2.7 or above

The import requests
The import json
The import OS
The import sys

Toparty="1" id # department
AgentID=1 # application id

# modified CropID for the enterprise and Secret
CropID='1'
Secret='1'

# access Token
Gtoken="HTTP://https://qyapi.weixin.qq.com/cgi-bin/gettoken? CropID corpid="+ +" & amp; Corpsecret="+ Secret
The content-type headers={' ':' application/json '}
Json_data=https://bbs.csdn.net/topics/json.loads (requests. Get (Gtoken). The decode ())
Token=json_data (" access_token ")

# message is sent by qing
Purl="HTTP://https://qyapi.weixin.qq.com/cgi-bin/message/send? Access_token="+ token

# message sending letter Ti
Def MSG (title, message) :
Weixin_msg={
"Toparty" : toparty,
"Msgtype" : "textcard,"
"Agentid", agentid,
"Textcard" : {
"Title" : the title,
"Description" : message,
"Url" : "http://192.168.0.88",
"BTNTXT" : "more"
}
}
Print requests. Post (Purl, json. Dumps (weixin_msg), headers=headers)

If __name__=="__main__ ':
Title=sys. Argv [1] # to get the first join Ti
Message=sys. Argv [2] # for the second parameter Ti
MSG (title, message)

CodePudding user response:

The message is the third argument, not the second
  • Related