diff --git a/Fix-the-problem-that-function-cpu_report_result-is-c.patch b/Fix-the-problem-that-function-cpu_report_result-is-c.patch new file mode 100644 index 0000000000000000000000000000000000000000..7a465900634e4df964ec6e1ca1b0dacb39a286f9 --- /dev/null +++ b/Fix-the-problem-that-function-cpu_report_result-is-c.patch @@ -0,0 +1,35 @@ +From 3e2721852ad1f8047ad219a5ab6c68fd4c9d6f5c Mon Sep 17 00:00:00 2001 +From: shixuantong +Date: Wed, 24 Jul 2024 16:17:54 +0800 +Subject: [PATCH] Fix the problem that function cpu_report_result() is called + more than once + +when task is running, user to exec "sentryctl stop cpu_sentry", cpu_report_result() will be called twice. This will cause the log to be printed twice +--- + src/python/syssentry/cpu_sentry.py | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/src/python/syssentry/cpu_sentry.py b/src/python/syssentry/cpu_sentry.py +index 7e77654..3c4d58d 100644 +--- a/src/python/syssentry/cpu_sentry.py ++++ b/src/python/syssentry/cpu_sentry.py +@@ -133,6 +133,7 @@ class CpuSentry: + + result_level = self.send_result.get("result", ResultLevel.FAIL) + report_result(task_name, result_level, details) ++ self.init_send_result() + + def kill_process(signum, _f, cpu_sentry_obj): + """kill process by 'pkill -9'""" +@@ -179,6 +180,6 @@ def main(): + cpu_sentry_task.send_result["result"] = ResultLevel.FAIL + cpu_sentry_task.send_result["details"]["code"] = 1004 + cpu_sentry_task.send_result["details"]["msg"] = "run cmd [%s] raise Error" % cpu_sentry_task_cmd +- finally: + cpu_sentry_task.cpu_report_result() +- cpu_sentry_task.init_send_result() ++ else: ++ cpu_sentry_task.cpu_report_result() +-- +2.27.0 + diff --git a/fix-error-handling.patch b/fix-error-handling.patch new file mode 100644 index 0000000000000000000000000000000000000000..faadc7adf748d3dbfd8e28be6959d1a1d4d74aac --- /dev/null +++ b/fix-error-handling.patch @@ -0,0 +1,25 @@ +From 370b22b032dce9290eebca1cf8d48bd155164b6a Mon Sep 17 00:00:00 2001 +From: shixuantong +Date: Wed, 24 Jul 2024 17:53:58 +0800 +Subject: [PATCH] fix error handling + +--- + src/python/syssentry/cpu_sentry.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/python/syssentry/cpu_sentry.py b/src/python/syssentry/cpu_sentry.py +index 3c4d58d..d0bafa8 100644 +--- a/src/python/syssentry/cpu_sentry.py ++++ b/src/python/syssentry/cpu_sentry.py +@@ -87,7 +87,7 @@ class CpuSentry: + } + + def handle_cpu_output(self, stdout: str): +- if "" in stdout: ++ if "ERROR" in stdout: + self.send_result["result"] = ResultLevel.FAIL + self.send_result["details"]["code"] = 1004 + self.send_result["details"]["msg"] = stdout.split("\n")[0] +-- +2.27.0 + diff --git a/sysSentry.spec b/sysSentry.spec index e10ba0265d7b32c8f210c6c1893521ab8df517a0..6bc93aa697247438b607619533ca30368071fa81 100644 --- a/sysSentry.spec +++ b/sysSentry.spec @@ -4,13 +4,15 @@ Summary: System Inspection Framework Name: sysSentry Version: 1.0.2 -Release: 2 +Release: 3 License: Mulan PSL v2 Group: System Environment/Daemons Source0: https://gitee.com/openeuler/sysSentry/releases/download/v%{version}/%{name}-%{version}.tar.gz BuildRoot: %{_builddir}/%{name}-root Patch1: fix-version-in-setup.py.patch +Patch2: Fix-the-problem-that-function-cpu_report_result-is-c.patch +Patch3: fix-error-handling.patch BuildRequires: cmake gcc-c++ BuildRequires: python3 python3-setuptools @@ -167,6 +169,13 @@ rm -rf %{buildroot} %attr(0550,root,root) %{python3_sitelib}/syssentry/cpu_* %changelog +* Thu Jul 25 2024 shixuantong - 1.0.2-3 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:Fix the problem that function cpu_report_result() is called more than once + fix error handling + * Tue Jun 18 2024 shixuantong - 1.0.2-2 - Type:bugfix - CVE:NA