|
@@ -1,5 +1,5 @@
|
|
|
from datetime import datetime, time
|
|
from datetime import datetime, time
|
|
|
-from typing import List, Tuple
|
|
|
|
|
|
|
+from typing import List
|
|
|
|
|
|
|
|
from aliyun.log import LogClient
|
|
from aliyun.log import LogClient
|
|
|
from aliyun.log.auth import AUTH_VERSION_4
|
|
from aliyun.log.auth import AUTH_VERSION_4
|
|
@@ -86,13 +86,17 @@ def job_run_state(start_ts: int, end_ts: int):
|
|
|
feishu_inform_util.send_card_msg_to_feishu(webhook, new_card_json)
|
|
feishu_inform_util.send_card_msg_to_feishu(webhook, new_card_json)
|
|
|
|
|
|
|
|
|
|
|
|
|
-def crawler_mode_not_success_warning(start_ts: int, end_ts: int, crawler_mode_and_video_source_list: List[Tuple[str, str]]):
|
|
|
|
|
- for crawler_mode, video_source in crawler_mode_and_video_source_list:
|
|
|
|
|
|
|
+def crawler_mode_not_success_warning(start_ts: int, end_ts: int, job_info_list: List[AutomationJobCronInfo]):
|
|
|
|
|
+ for job_info in job_info_list:
|
|
|
|
|
+ crawler_mode = job_info.crawler_mode
|
|
|
|
|
+ video_source = job_info.video_source
|
|
|
|
|
+ job_name = job_info.name
|
|
|
|
|
+
|
|
|
query_sql = f"crawlerMode : {crawler_mode} and videoSource : {video_source} and result : true | select count(1) as cnt from log"
|
|
query_sql = f"crawlerMode : {crawler_mode} and videoSource : {video_source} and result : true | select count(1) as cnt from log"
|
|
|
resp = client.get_log(project=project, logstore=log_store, from_time=start_ts, to_time=end_ts, query=query_sql)
|
|
resp = client.get_log(project=project, logstore=log_store, from_time=start_ts, to_time=end_ts, query=query_sql)
|
|
|
success_cnt = int(resp.get_body().get('data')[0]['cnt'])
|
|
success_cnt = int(resp.get_body().get('data')[0]['cnt'])
|
|
|
if success_cnt <= 0:
|
|
if success_cnt <= 0:
|
|
|
- msg = f"- 供给方式: {crawler_mode} \n- 视频来源: {video_source} \n- 当天还没有成功执行的任务,请关注"
|
|
|
|
|
|
|
+ msg = f"- 供给方式: {job_name} \n- 视频来源: {video_source} \n- 当天还没有成功执行的任务,请关注"
|
|
|
new_card_json = {**card_json, **{}}
|
|
new_card_json = {**card_json, **{}}
|
|
|
new_card_json['header']['template'] = 'red'
|
|
new_card_json['header']['template'] = 'red'
|
|
|
new_card_json['body']['elements'] = [{
|
|
new_card_json['body']['elements'] = [{
|
|
@@ -116,14 +120,14 @@ def main():
|
|
|
|
|
|
|
|
current_hour = today.hour
|
|
current_hour = today.hour
|
|
|
|
|
|
|
|
- crawler_mode_and_video_source_list = []
|
|
|
|
|
|
|
+ need_monitor_job_info_list = []
|
|
|
for cron_info in AutomationJobCronInfo:
|
|
for cron_info in AutomationJobCronInfo:
|
|
|
if current_hour < cron_info.task_start_hour:
|
|
if current_hour < cron_info.task_start_hour:
|
|
|
continue
|
|
continue
|
|
|
|
|
|
|
|
- crawler_mode_and_video_source_list.append((cron_info.crawler_mode, cron_info.video_source))
|
|
|
|
|
|
|
+ need_monitor_job_info_list.append(cron_info)
|
|
|
|
|
|
|
|
- crawler_mode_not_success_warning(start_ts, end_ts, crawler_mode_and_video_source_list)
|
|
|
|
|
|
|
+ crawler_mode_not_success_warning(start_ts, end_ts, need_monitor_job_info_list)
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
if __name__ == "__main__":
|