Commit d8e6d9af by 陈森彬

添加微信告警机器人

parent d1a4fdde
Showing with 7 additions and 4 deletions
...@@ -7,6 +7,9 @@ import re ...@@ -7,6 +7,9 @@ import re
dd_robot_api = ' https://oapi.dingtalk.com/robot/send?access_token=' dd_robot_api = ' https://oapi.dingtalk.com/robot/send?access_token='
tom = 'c19beeab837f5c6e019e7fc602d470704d634ae33510f40fb0e903cde215fb24' tom = 'c19beeab837f5c6e019e7fc602d470704d634ae33510f40fb0e903cde215fb24'
wechat_robot_api = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key="
tom_key = "bb2b5b4e-9a06-4d3d-89f5-61bcf07ed4ba"
filter_plat_kw = ['pc', 'bkc'] filter_plat_kw = ['pc', 'bkc']
wrong_ratio_pat = re.compile(r'\d\d\.\d\d') wrong_ratio_pat = re.compile(r'\d\d\.\d\d')
msgapi_url = 'http://api.ichunt.com/msg/sendMessageByAuto' msgapi_url = 'http://api.ichunt.com/msg/sendMessageByAuto'
...@@ -29,14 +32,14 @@ def parse_msg(msg): ...@@ -29,14 +32,14 @@ def parse_msg(msg):
return msgs return msgs
def dd_send_msg(msg, robot=tom): def dd_send_msg(msg, robot=tom_key):
data = { data = {
"msgtype": "text", "msgtype": "text",
"text": { "text": {
"content": msg "content": msg
} }
} }
requests.post(dd_robot_api + robot, json=data) requests.post(wechat_robot_api + robot, json=data)
time.sleep(5) time.sleep(5)
phone_msgs = parse_msg(msg) phone_msgs = parse_msg(msg)
...@@ -55,10 +58,10 @@ def dd_send_msg(msg, robot=tom): ...@@ -55,10 +58,10 @@ def dd_send_msg(msg, robot=tom):
'fromuser': '', 'wechat_data': '', 'is_oversea': '', 'channel_type': '', 'is_ignore': '', 'ex_int': '', 'fromuser': '', 'wechat_data': '', 'is_oversea': '', 'channel_type': '', 'is_ignore': '', 'ex_int': '',
'ex_str': '', 'k2': d.hexdigest(), 'k1': str(cur_time)} 'ex_str': '', 'k2': d.hexdigest(), 'k1': str(cur_time)}
requests.post(msgapi_url, data=data) requests.post(msgapi_url, data=data)
# print("didididi")
if __name__ == "__main__": if __name__ == "__main__":
dd_send_msg('''TAS任务监控预警 过去90分钟内: dd_send_msg('''测试 TAS任务监控预警 过去90分钟内:
任务:muguf 未知 平均错误率为81.30% 任务:muguf 未知 平均错误率为81.30%
任务:pc 平台比价 平均错误率为97.99% 任务:pc 平台比价 平均错误率为97.99%
任务:bkc buerklin新品采集 平均错误率为72.97%''') 任务:bkc buerklin新品采集 平均错误率为72.97%''')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment