Zabbix3.4 designated users can receive configuration alarm 1 download micro letter python script. # Installation simplejson wget HTTPS: // pypi.python.org/packages/f0/07/26b519e6ebb03c2a74989f7571e6ae6b82e9d7d81b8de6fcdbfc643c7b58/simplejson-3.8.2.tar.gz git address : HTTPS: // github.com/simplejson/simplejson/tree/v3.8.2 tar zxvf simplejson- 3.8 . 2 . tar .gz && cd simplejson- 3.8 . 2 Python setup.py Build Python setup.py install # download wechat. py script git clone HTTPS: // github.com/X-Mars/Zabbix-Alert-WeChat.git cpWeChat-Alert-zabbix / wechat.py / usr / lib / zabbix / alertscripts / chmod + the X-wechat.py && chown zabbix: zabbix wechat.py edit the script, will apply to the relevant information to fill in wechat.py [root @ szxxlfhtest02t: / usr / lib / zabbix / alertscripts] # CAT wechat.py # / usr / bin /! Python #_ * _coding: UTF- 8 _ * _ #auther: Mars Liu Import Requests, SYS, json Import urllib3 urllib3 .disable_warnings () reload (SYS) sys.setdefaultencoding ( ' UTF-. 8 ' ) DEF the GetToken (Corpid, Secret): the Url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken" Data = { "corpid":Corpid, "corpsecret":Secret } r = requests.get(url=Url,params=Data,verify=False) Token = r.json()['access_token'] return Token def SendMessage(Token,User,Agentid,Subject,Content): Url = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=%s" % Token Data = { "TOUSER " : the User, # Enterprise user accounts, user zabbix Media in the configuration, if not configured properly, departments will send. # " totag " : TAGID, label id # in Enterprise, mass use (recommended) # " toparty " : the partyId # enterprise in the department id, use mass. " MsgType " : " text " , # message type. " agentid " : agentid, # enterprise application of the above mentioned id. " text " : { "content": Subject + ' \ N- ' + the Content }, " Safe " : " 0 " } R & lt = requests.post (= the Url URL, Data = json.dumps (the Data), Verify = False) return r.text IF the __name__ == ' __main__ ' : the User = the sys.argv [ . 1 ] # ZABBIX pass over the first parameter of the Subject = the sys.argv [ 2 ] # ZABBIX second parameter pass over the Content = the sys.argv [ . 3] # Zabbix pass over the third parameter Corpid = " copid " # CorpID is the identification number of enterprise Secret = " sec " # Secret key is to manage the set of credentials #Tagid = " 1 " # Contacts tag ID agentid = " 1000002 " # application ID #Partyid = " . 1 " # 部门ID Token = GetToken(Corpid, Secret) Status = SendMessage(Token,User,Agentid,Subject,Content) print Status
Action Configuration