fix the sentryCollector service can't be stopped for a long

Signed-off-by: zhuofeng <1107893276@qq.com>
This commit is contained in:
zhuofeng 2025-03-13 02:08:40 +00:00 committed by Gitee
parent 4fd8aa3dea
commit a2367330fa
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 69 additions and 1 deletions

View File

@ -0,0 +1,61 @@
From 411e0fe141efdf02d73aa15c2576214af1be787e Mon Sep 17 00:00:00 2001
From: zhuofeng <1107893276@qq.com>
Date: Wed, 12 Mar 2025 02:27:12 +0000
Subject: [PATCH] fix the sentryCollector service can't be stopped for a long
time
Signed-off-by: zhuofeng <1107893276@qq.com>
---
src/python/sentryCollector/collect_io.py | 13 +++++++++++--
src/python/syssentry/global_values.py | 2 +-
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/python/sentryCollector/collect_io.py b/src/python/sentryCollector/collect_io.py
index 4cf6534..622e0b4 100644
--- a/src/python/sentryCollector/collect_io.py
+++ b/src/python/sentryCollector/collect_io.py
@@ -322,6 +322,8 @@ class CollectIo():
if curr_io_dump > 0:
logging.info(f"ebpf io_dump info : {disk_name}, {stage}, {io_type}, {curr_io_dump}")
IO_GLOBAL_DATA[disk_name][stage][io_type].insert(0, [curr_lat, curr_io_dump, curr_io_length, curr_iops])
+ if curr_lat > 0:
+ logging.info(f"ebpf info : {disk_name}, {stage}, {io_type}, {curr_lat}, {curr_iops}")
elapsed_time = time.time() - start_time
sleep_time = self.period_time - elapsed_time
@@ -405,10 +407,17 @@ class CollectIo():
self
) -> None:
global EBPF_PROCESS
- if EBPF_PROCESS:
+ if not EBPF_PROCESS:
+ logging.debug("No eBPF process to stop")
+ return
+ try:
EBPF_PROCESS.terminate()
+ EBPF_PROCESS.wait(timeout=3)
+ except subprocess.TimeoutExpired:
+ logging.debug("eBPF process did not exit within timeout. Forcing kill.")
+ EBPF_PROCESS.kill()
EBPF_PROCESS.wait()
- logging.info("ebpf collector thread exit")
+ logging.info("ebpf collector thread exit")
def main_loop(self):
global IO_GLOBAL_DATA
diff --git a/src/python/syssentry/global_values.py b/src/python/syssentry/global_values.py
index b123b2d..9c7800b 100644
--- a/src/python/syssentry/global_values.py
+++ b/src/python/syssentry/global_values.py
@@ -114,7 +114,7 @@ class InspectTask:
try:
child = subprocess.Popen(cmd_list, stdout=logfile, stderr=subprocess.STDOUT, close_fds=True)
except OSError:
- logging.error("task %s start Popen error, invalid cmd")
+ logging.error("task %s start Popen error, invalid cmd", cmd_list)
self.result_info["result"] = ResultLevel.FAIL.name
self.result_info["error_msg"] = RESULT_LEVEL_ERR_MSG_DICT.get(ResultLevel.FAIL.name)
self.runtime_status = "FAILED"
--
2.43.0

View File

@ -4,7 +4,7 @@
Summary: System Inspection Framework
Name: sysSentry
Version: 1.0.2
Release: 31
Release: 32
License: Mulan PSL v2
Group: System Environment/Daemons
Source0: https://gitee.com/openeuler/sysSentry/releases/download/v%{version}/%{name}-%{version}.tar.gz
@ -41,6 +41,7 @@ Patch28: adapt_5.10_kenel_for_syssentry.patch
Patch29: collect-module-adapt-to-the-5.10-kernel.patch
Patch30: add-avg_block_io-and-ai_block_io.patch
Patch31: fix-bug-of-ebpf-and-ai_block_io.patch
Patch32: fix-the-sentryCollector-service-can-t-be-stopped-for.patch
BuildRequires: cmake gcc-c++
BuildRequires: python3 python3-setuptools
@ -358,6 +359,12 @@ rm -rf %{buildroot}
%attr(0550,root,root) %{python3_sitelib}/sentryCollector/__pycache__/collect_plugin*
%changelog
* Thu Mar 13 2025 zhuofeng <zhuofeng2@huawei.com> - 1.0.2-32
- Type:bugfix
- CVE:NA
- SUG:NA
- DESC:fix the sentryCollector service can't be stopped for a long
* Fri Feb 14 2025 zhuofeng <zhuofeng2@huawei.com> - 1.0.2-31
- Type:bugfix
- CVE:NA