Commit f4f041ea by 陈森彬

update

parent c0468bad
Showing with 2 additions and 6 deletions
...@@ -67,10 +67,7 @@ def get_error_ratio(task_code, time_range=30): ...@@ -67,10 +67,7 @@ def get_error_ratio(task_code, time_range=30):
res = requests.post(url,json=query) res = requests.post(url,json=query)
# value = response['aggregations']['avgFailRate']['value'] # value = response['aggregations']['avgFailRate']['value']
print("-_________") value = res.json()['aggregations']['avgFailRate']['value'] if res.status_code==200 else 0.0
print(res.json())
print(task_code)
value = res.json()['aggregations']['avgFailRate']['value'] if res.status_code!=200 else 0.0
return round(value, 3) return round(value, 3)
...@@ -96,7 +93,6 @@ def get_crawler_process_info(): ...@@ -96,7 +93,6 @@ def get_crawler_process_info():
info_dict['run_time'] = round(sum(info['cpu_times']), 3) info_dict['run_time'] = round(sum(info['cpu_times']), 3)
info_dict['remain_task'], info_dict['remain_wrong_task'] = get_process_task(info_dict['task_code']) info_dict['remain_task'], info_dict['remain_wrong_task'] = get_process_task(info_dict['task_code'])
info_dict['wrong_radio'] = get_error_ratio(info_dict['task_code']) info_dict['wrong_radio'] = get_error_ratio(info_dict['task_code'])
print(info_dict['task_code'],info_dict['wrong_radio'])
process[info_dict['unique_code']] = info_dict process[info_dict['unique_code']] = info_dict
return process return process
......
...@@ -126,7 +126,7 @@ def get_task_error_rate(time_range=30, error_rate=30): ...@@ -126,7 +126,7 @@ def get_task_error_rate(time_range=30, error_rate=30):
res = requests.post(url, json=query) res = requests.post(url, json=query)
# value = response['aggregations']['avgFailRate']['value'] # value = response['aggregations']['avgFailRate']['value']
buckets = res.json()['aggregations']['avgFailRate']['value'] if res.status_code != 200 and res.json()['aggregations']['taskCodes']['buckets'] else "" buckets = res.json()['aggregations']['avgFailRate']['value'] if res.status_code == 200 and res.json()['aggregations']['taskCodes']['buckets'] else ""
if buckets: if buckets:
return gen_msg(time_range, buckets) return gen_msg(time_range, buckets)
return return
......
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