Commit ace1d9ff by lichenggang

digikey token同步失败加入短信告警

parent a74e894d
Showing with 14 additions and 1 deletions
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import hashlib
import time
import requests
dd_robot_api = ' https://oapi.dingtalk.com/robot/send?access_token='
tom = 'c19beeab837f5c6e019e7fc602d470704d634ae33510f40fb0e903cde215fb24'
msgapi_url = 'http://api.ichunt.com/msg/sendMessageByAuto'
def dd_send_msg(msg, robot=tom):
data = {
......@@ -17,7 +18,19 @@ def dd_send_msg(msg, robot=tom):
}
requests.post(dd_robot_api + robot, json=data)
time.sleep(5)
if 'digikey' in msg:
content = 'digikey token同步失败'
cur_time = int(time.time())
m = hashlib.md5()
d = hashlib.md5()
m.update(str(cur_time).encode())
d.update((m.hexdigest() + 'fh6y5t4rr351d2c3bryi').encode())
data = {'data': "{\"content\": \"%s\"}" % (content), 'touser': "[\"15113123231\",\"18594239421\"]", 'keyword': 'monitoring-py',
'fromuser': '', 'wechat_data': '', 'is_oversea': '', 'channel_type': '', 'is_ignore': '', 'ex_int': '',
'ex_str': '', 'k2': d.hexdigest(), 'k1': str(cur_time)}
requests.post(msgapi_url, data=data)
if __name__ == "__main__":
dd_send_msg('喂喂 你发的太多了!')
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