From d8203b6c6dfe7f67db0195f458bf5f9b448d839a Mon Sep 17 00:00:00 2001 From: Caohongtao Date: Thu, 5 Sep 2024 09:55:04 +0000 Subject: [PATCH] Add judgment conditions fix! if the file not exist ,it will "FileNotFoundError" Signed-off-by: Caohongtao --- sysSentry-1.0.2/src/python/syssentry/sentry_config.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sysSentry-1.0.2/src/python/syssentry/sentry_config.py b/sysSentry-1.0.2/src/python/syssentry/sentry_config.py index 01f3df8..55f3c03 100644 --- a/sysSentry-1.0.2/src/python/syssentry/sentry_config.py +++ b/sysSentry-1.0.2/src/python/syssentry/sentry_config.py @@ -79,8 +79,10 @@ class CpuPluginsParamsConfig: @staticmethod def get_cpu_info(): - with open("/sys/devices/system/cpu/present", "r") as f: - cpu_list = f.readline() + cpu_list='' + if os.path.exists("/sys/devices/system/cpu/present"): + with open("/sys/devices/system/cpu/present", "r") as f: + cpu_list = f.readline() return cpu_list.strip() @staticmethod -- Gitee