From 731a439222be43f87a4b782d4817bb751a5c512d Mon Sep 17 00:00:00 2001 From: vapao Date: Wed, 1 Jul 2020 22:48:20 +0800 Subject: [PATCH] =?UTF-8?q?U=20=E4=BC=98=E5=8C=96=E7=9B=91=E6=8E=A7?= =?UTF-8?q?=E5=91=8A=E8=AD=A6=E6=8F=8F=E8=BF=B0=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spug_api/apps/monitor/executors.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spug_api/apps/monitor/executors.py b/spug_api/apps/monitor/executors.py index 478804f..001a496 100644 --- a/spug_api/apps/monitor/executors.py +++ b/spug_api/apps/monitor/executors.py @@ -24,7 +24,7 @@ def port_check(addr, port): sock = socket() sock.settimeout(5) sock.connect((addr, int(port))) - return True, None + return True, '端口状态检测正常' except Exception as e: return False, f'异常信息:{e}' @@ -33,7 +33,10 @@ def host_executor(host, pkey, command): try: cli = SSH(host.hostname, host.port, host.username, pkey=pkey) exit_code, out = cli.exec_command(command) - return exit_code == 0, out.decode() + if exit_code == 0: + return True, out.decode() or '检测状态正常' + else: + return False, out.decode() or f'退出状态码:{exit_code}' except Exception as e: return False, f'异常信息:{e}'