From f084a4dcce89558a5703cc0c7ae85ffb9cf4462e Mon Sep 17 00:00:00 2001 From: vapao Date: Mon, 6 Dec 2021 16:12:10 +0800 Subject: [PATCH] =?UTF-8?q?U=20=E4=BC=98=E5=8C=96=E7=AB=99=E7=82=B9?= =?UTF-8?q?=E6=A3=80=E6=B5=8B=E5=BC=82=E5=B8=B8=E4=BF=A1=E6=81=AF=E8=BE=93?= =?UTF-8?q?=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spug_api/apps/monitor/executors.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/spug_api/apps/monitor/executors.py b/spug_api/apps/monitor/executors.py index f759267..057c45d 100644 --- a/spug_api/apps/monitor/executors.py +++ b/spug_api/apps/monitor/executors.py @@ -12,8 +12,10 @@ import requests import logging import json import time +import re logging.captureWarnings(True) +regex = re.compile(r'Failed to establish a new connection: (.*)\'\)+') def site_check(url, limit): @@ -25,7 +27,11 @@ def site_check(url, limit): return False, f'响应时间:{duration}ms' return 200 <= res.status_code < 400, f'返回状态码:{res.status_code}' except Exception as e: - return False, f'异常信息:{e}' + error = e.__str__() + exps = re.findall(regex, error) + if exps: + error = exps[0] + return False, error def port_check(addr, port):