optimize the handing of cat-cli error msg in cpu_sentry
This commit is contained in:
parent
be135dedaa
commit
6e33378214
@ -0,0 +1,77 @@
|
|||||||
|
From cb3d0ea18eed3d48f2753f878d9726f58fe616b1 Mon Sep 17 00:00:00 2001
|
||||||
|
From: shixuantong <shixuantong1@huawei.com>
|
||||||
|
Date: Sat, 21 Sep 2024 09:53:42 +0800
|
||||||
|
Subject: [PATCH] optimize the handing of cat-cli error msg in cpu_sentry
|
||||||
|
|
||||||
|
---
|
||||||
|
src/python/syssentry/cpu_sentry.py | 36 +++++++++++++++++-------------
|
||||||
|
1 file changed, 21 insertions(+), 15 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/python/syssentry/cpu_sentry.py b/src/python/syssentry/cpu_sentry.py
|
||||||
|
index 99af127..582d4b3 100644
|
||||||
|
--- a/src/python/syssentry/cpu_sentry.py
|
||||||
|
+++ b/src/python/syssentry/cpu_sentry.py
|
||||||
|
@@ -26,6 +26,8 @@ CPU_SENTRY_PARAM_CONFIG = "/etc/sysSentry/plugins/cpu_sentry.ini"
|
||||||
|
# Inspection commands running at the bottom layer
|
||||||
|
LOW_LEVEL_INSPECT_CMD = "cat-cli"
|
||||||
|
|
||||||
|
+# max length of msg in details
|
||||||
|
+DETAILS_LOG_MSG_MAX_LEN = 255
|
||||||
|
|
||||||
|
class CpuSentry:
|
||||||
|
"""
|
||||||
|
@@ -94,22 +96,10 @@ class CpuSentry:
|
||||||
|
self.send_result["details"]["msg"] = "cpu_sentry task is killed!"
|
||||||
|
return
|
||||||
|
|
||||||
|
- if "ERROR" in stdout:
|
||||||
|
- self.send_result["result"] = ResultLevel.FAIL
|
||||||
|
- self.send_result["details"]["code"] = 1004
|
||||||
|
-
|
||||||
|
- # Remove ANSI escape sequences
|
||||||
|
- error_info = stdout.split("\n")[0]
|
||||||
|
- if error_info.startswith("\u001b"):
|
||||||
|
- ansi_escape = r'\x1b\[([0-9]+)(;[0-9]+)*([A-Za-z])'
|
||||||
|
- error_info = re.sub(ansi_escape, '', error_info)
|
||||||
|
-
|
||||||
|
- self.send_result["details"]["msg"] = error_info
|
||||||
|
- return
|
||||||
|
-
|
||||||
|
out_split = stdout.split("\n")
|
||||||
|
- isolated_cores_number = 0
|
||||||
|
+ isolated_cores_number = -1
|
||||||
|
found_fault_cores_list = []
|
||||||
|
+ error_msg_list = []
|
||||||
|
for out_line_i in out_split:
|
||||||
|
if "handle_patrol_result: Found fault cores" in out_line_i:
|
||||||
|
cores_number_tmp = out_line_i.split("Found fault cores:")[1]
|
||||||
|
@@ -121,9 +111,25 @@ class CpuSentry:
|
||||||
|
elif out_line_i.startswith('<ISOLATED-CORE-LIST>'):
|
||||||
|
self.send_result["details"]["isolated_cpu_list"] = out_line_i.split(':')[1]
|
||||||
|
break
|
||||||
|
+ elif "ERROR" in out_line_i:
|
||||||
|
+ logging.error("[cat-cli error] - %s\n", out_line_i)
|
||||||
|
+ error_msg_list.append(out_line_i)
|
||||||
|
|
||||||
|
found_fault_cores_number = len(set(found_fault_cores_list))
|
||||||
|
- if found_fault_cores_number == 0:
|
||||||
|
+ if isolated_cores_number == -1:
|
||||||
|
+ self.send_result["result"] = ResultLevel.FAIL
|
||||||
|
+ self.send_result["details"]["code"] = 1004
|
||||||
|
+
|
||||||
|
+ send_error_msg = ""
|
||||||
|
+ # Remove ANSI escape sequences
|
||||||
|
+ for error_info in error_msg_list:
|
||||||
|
+ if error_info.startswith("\u001b"):
|
||||||
|
+ ansi_escape = r'\x1b\[([0-9]+)(;[0-9]+)*([A-Za-z])'
|
||||||
|
+ error_info = re.sub(ansi_escape, '', error_info)
|
||||||
|
+ if len(send_error_msg) + len(error_info) < DETAILS_LOG_MSG_MAX_LEN:
|
||||||
|
+ send_error_msg += error_info
|
||||||
|
+ self.send_result["details"]["msg"] = send_error_msg
|
||||||
|
+ elif found_fault_cores_number == 0:
|
||||||
|
self.send_result["details"]["code"] = 0
|
||||||
|
self.send_result["result"] = ResultLevel.PASS
|
||||||
|
elif 0 in found_fault_cores_list:
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
25
over-threshold-should-be-warn-level-log-in-cat-cli.patch
Normal file
25
over-threshold-should-be-warn-level-log-in-cat-cli.patch
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
From 3dda5f68db38b63b1e45a28558a9fcd341c1f945 Mon Sep 17 00:00:00 2001
|
||||||
|
From: jwolf <523083921@qq.com>
|
||||||
|
Date: Fri, 20 Sep 2024 15:59:40 +0800
|
||||||
|
Subject: [PATCH] should be warn-level log
|
||||||
|
|
||||||
|
---
|
||||||
|
src/c/catcli/catlib/plugin/cpu_patrol/cpu_patrol_result.c | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/src/c/catcli/catlib/plugin/cpu_patrol/cpu_patrol_result.c b/src/c/catcli/catlib/plugin/cpu_patrol/cpu_patrol_result.c
|
||||||
|
index 9f8d80c..f4f3172 100644
|
||||||
|
--- a/src/c/catcli/catlib/plugin/cpu_patrol/cpu_patrol_result.c
|
||||||
|
+++ b/src/c/catcli/catlib/plugin/cpu_patrol/cpu_patrol_result.c
|
||||||
|
@@ -23,7 +23,7 @@ static cat_return_t insert_core_to_list(core_list_st *core_list, int coreid)
|
||||||
|
return CAT_OK;
|
||||||
|
}
|
||||||
|
if ((core_list->current_nums == MAX_ISOLATE_CORES_PER_PATROL) || (coreid < 0)) {
|
||||||
|
- CAT_LOG_E("Insert error, core id(%d)", coreid);
|
||||||
|
+ CAT_LOG_W("Too many cores need to isolate,do not isolate core(%d)", coreid);
|
||||||
|
return CAT_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -4,7 +4,7 @@
|
|||||||
Summary: System Inspection Framework
|
Summary: System Inspection Framework
|
||||||
Name: sysSentry
|
Name: sysSentry
|
||||||
Version: 1.0.2
|
Version: 1.0.2
|
||||||
Release: 15
|
Release: 16
|
||||||
License: Mulan PSL v2
|
License: Mulan PSL v2
|
||||||
Group: System Environment/Daemons
|
Group: System Environment/Daemons
|
||||||
Source0: https://gitee.com/openeuler/sysSentry/releases/download/v%{version}/%{name}-%{version}.tar.gz
|
Source0: https://gitee.com/openeuler/sysSentry/releases/download/v%{version}/%{name}-%{version}.tar.gz
|
||||||
@ -26,6 +26,8 @@ Patch13: add-collect-module-to-sysSentry.patch
|
|||||||
Patch14: feature-add-avg_block_io-plugin.patch
|
Patch14: feature-add-avg_block_io-plugin.patch
|
||||||
Patch15: fix-some-about-collect-module-and-avg-block-io.patch
|
Patch15: fix-some-about-collect-module-and-avg-block-io.patch
|
||||||
Patch16: add-ai-threshold-slow-io-detection-plugin.patch
|
Patch16: add-ai-threshold-slow-io-detection-plugin.patch
|
||||||
|
Patch17: optimize-the-handing-of-cat-cli-error-msg-in-cpu_sentry.patch
|
||||||
|
Patch18: over-threshold-should-be-warn-level-log-in-cat-cli.patch
|
||||||
|
|
||||||
BuildRequires: cmake gcc-c++
|
BuildRequires: cmake gcc-c++
|
||||||
BuildRequires: python3 python3-setuptools
|
BuildRequires: python3 python3-setuptools
|
||||||
@ -244,6 +246,13 @@ rm -rf %{buildroot}
|
|||||||
%attr(0550,root,root) %{python3_sitelib}/sentryPlugins/ai_threshold_slow_io_detection
|
%attr(0550,root,root) %{python3_sitelib}/sentryPlugins/ai_threshold_slow_io_detection
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Sep 23 2024 shixuantong <shixuantong1@huawei.com> - 1.0.2-16
|
||||||
|
- Type:bugfix
|
||||||
|
- CVE:NA
|
||||||
|
- SUG:NA
|
||||||
|
- DESC:optimize the handing of cat-cli error msg in cpu_sentry
|
||||||
|
over threshold should be warn level log in cat-cli
|
||||||
|
|
||||||
* Mon Sep 23 2024 heyouzhi <heyouzhi@huawei.com> - 1.0.2-15
|
* Mon Sep 23 2024 heyouzhi <heyouzhi@huawei.com> - 1.0.2-15
|
||||||
- Type:requirement
|
- Type:requirement
|
||||||
- CVE:NA
|
- CVE:NA
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user