mirror of https://github.com/openspug/spug
fix issue
parent
76b5ea39de
commit
8c95bc35f7
|
@ -31,9 +31,11 @@ def _do_notify(task, mode, url, msg):
|
||||||
'markdown': {
|
'markdown': {
|
||||||
'title': '任务执行失败通知',
|
'title': '任务执行失败通知',
|
||||||
'text': '\n\n'.join(texts)
|
'text': '\n\n'.join(texts)
|
||||||
|
},
|
||||||
|
'at': {
|
||||||
|
'isAtAll': True
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
requests.post(url, json=data)
|
|
||||||
elif mode == '2':
|
elif mode == '2':
|
||||||
data = {
|
data = {
|
||||||
'task_id': task.id,
|
'task_id': task.id,
|
||||||
|
@ -42,7 +44,6 @@ def _do_notify(task, mode, url, msg):
|
||||||
'message': msg or '请在任务计划执行历史中查看详情',
|
'message': msg or '请在任务计划执行历史中查看详情',
|
||||||
'created_at': human_datetime()
|
'created_at': human_datetime()
|
||||||
}
|
}
|
||||||
requests.post(url, json=data)
|
|
||||||
elif mode == '3':
|
elif mode == '3':
|
||||||
texts = [
|
texts = [
|
||||||
'## <font color="warning">任务执行失败通知</font>',
|
'## <font color="warning">任务执行失败通知</font>',
|
||||||
|
@ -58,10 +59,12 @@ def _do_notify(task, mode, url, msg):
|
||||||
'content': '\n'.join(texts)
|
'content': '\n'.join(texts)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
res = requests.post(url, json=data)
|
else:
|
||||||
if res.status_code != 200:
|
return
|
||||||
Notify.make_notify('schedule', '1', '任务执行通知发送失败', f'返回状态码:{res.status_code}, 请求URL:{url}')
|
res = requests.post(url, json=data)
|
||||||
if mode in ['1', '3']:
|
if res.status_code != 200:
|
||||||
res = res.json()
|
Notify.make_notify('schedule', '1', '任务执行通知发送失败', f'返回状态码:{res.status_code}, 请求URL:{url}')
|
||||||
if res.get('errcode') != 0:
|
if mode in ['1', '3']:
|
||||||
Notify.make_notify('schedule', '1', '任务执行通知发送失败', f'返回数据:{res}')
|
res = res.json()
|
||||||
|
if res.get('errcode') != 0:
|
||||||
|
Notify.make_notify('schedule', '1', '任务执行通知发送失败', f'返回数据:{res}')
|
||||||
|
|
|
@ -121,6 +121,9 @@ class Notification:
|
||||||
'markdown': {
|
'markdown': {
|
||||||
'title': '监控告警通知',
|
'title': '监控告警通知',
|
||||||
'text': '\n\n'.join(texts) + '\n\n> ###### 来自 Spug运维平台'
|
'text': '\n\n'.join(texts) + '\n\n> ###### 来自 Spug运维平台'
|
||||||
|
},
|
||||||
|
'at': {
|
||||||
|
'isAtAll': True
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for url in users:
|
for url in users:
|
||||||
|
|
Loading…
Reference in New Issue