企業微信接收到zabbix告警資訊標題
點擊更多后出現
配置的動作如下
報警媒介中的腳本引數如下
腳本代碼
#!/usr/bin/python
# -*- coding: utf-8 -*-
# zabbix notification confirmation script
# python2.7 or above
import requests
import json
import os
import sys
Toparty = "1" #部門id
AgentID = 1 #應用id
#修改為企業CropID和Secret
CropID = '1'
Secret = '1'
#獲取Token
Gtoken ="https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid="+ CropID + "&corpsecret=" + Secret
headers = {'Content-Type': 'application/json'}
json_data = json.loads(requests.get(Gtoken).content.decode())
token = json_data["access_token"]
#訊息發送接卿
Purl = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=" + token
#訊息發送函擿
def msg(title,message):
weixin_msg = {
"toparty" : Toparty,
"msgtype" : "textcard",
"agentid" : AgentID,
"textcard" : {
"title" : title,
"description" : message,
"url" : "http://192.168.0.88",
"btntxt":"更多"
}
}
print requests.post(Purl,json.dumps(weixin_msg),headers=headers)
if __name__ == '__main__':
title = sys.argv[1] #獲取第一個參擿
message = sys.argv[2] #獲取第二個參擿
msg(title,message)
uj5u.com熱心網友回復:
message是第三個引數,不是第二個轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/139419.html
下一篇:求助!關于encrypt問題!
