!115 fix ebpf iodump warning
From: @znzjugod Reviewed-by: @gaoruoshu Signed-off-by: @gaoruoshu
This commit is contained in:
commit
c62c210bfa
77
ebpf-fix-iodump-warning.patch
Normal file
77
ebpf-fix-iodump-warning.patch
Normal file
@ -0,0 +1,77 @@
|
||||
From cd7b99efa20bc76cebffefbd711b0e0b5cbb5472 Mon Sep 17 00:00:00 2001
|
||||
From: zhangnan <zhangnan134@huawei.com>
|
||||
Date: Wed, 16 Oct 2024 22:08:42 +0800
|
||||
Subject: [PATCH] ebpf fix collect iodump
|
||||
|
||||
---
|
||||
src/c/ebpf_collector/ebpf_collector.c | 27 +++++++++++-------------
|
||||
src/python/sentryCollector/collect_io.py | 2 +-
|
||||
2 files changed, 13 insertions(+), 16 deletions(-)
|
||||
|
||||
diff --git a/src/c/ebpf_collector/ebpf_collector.c b/src/c/ebpf_collector/ebpf_collector.c
|
||||
index 0885a5f..af452c8 100644
|
||||
--- a/src/c/ebpf_collector/ebpf_collector.c
|
||||
+++ b/src/c/ebpf_collector/ebpf_collector.c
|
||||
@@ -119,23 +119,19 @@ char* find_device_name(dev_t dev) {
|
||||
|
||||
static void update_io_dump(struct bpf_map *map_res, int *io_dump, int *map_size, char *stage) {
|
||||
struct time_range_io_count time_count;
|
||||
- u32 io_dump_key = 0, io_dump_next_key = 0;
|
||||
+ u32 io_dump_key = 0;
|
||||
struct sysinfo info;
|
||||
sysinfo(&info);
|
||||
-
|
||||
- while (bpf_map_get_next_key(map_res, &io_dump_key, &io_dump_next_key) == 0) {
|
||||
- int err = bpf_map_lookup_elem(map_res, &io_dump_next_key, &time_count);
|
||||
- if (err < 0) {
|
||||
- fprintf(stderr, "failed to lookup %s io dump: %d\n", stage, err);
|
||||
- break;
|
||||
- }
|
||||
- if (io_dump_key == io_dump_next_key) {
|
||||
- break;
|
||||
+ int count_time = 150;
|
||||
+ u32 curr_time = info.uptime;
|
||||
+ while (count_time >= 0) {
|
||||
+ io_dump_key = curr_time - count_time;
|
||||
+ int err = bpf_map_lookup_elem(map_res, &io_dump_key, &time_count);
|
||||
+ if (err < 0) {
|
||||
+ count_time -= 1;
|
||||
+ continue;
|
||||
}
|
||||
-
|
||||
- io_dump_key = io_dump_next_key;
|
||||
-
|
||||
- if ((info.uptime - io_dump_key) >= 2) {
|
||||
+ if ((curr_time - io_dump_key) >= 2) {
|
||||
int isempty = 1;
|
||||
for (int key = 0; key < map_size; key++) {
|
||||
if (time_count.count[key] > 0) {
|
||||
@@ -143,10 +139,11 @@ static void update_io_dump(struct bpf_map *map_res, int *io_dump, int *map_size,
|
||||
isempty = 0;
|
||||
}
|
||||
}
|
||||
- if (isempty || (info.uptime - io_dump_key) > IO_DUMP_THRESHOLD) {
|
||||
+ if (isempty || (curr_time - io_dump_key) > IO_DUMP_THRESHOLD) {
|
||||
bpf_map_delete_elem(map_res, &io_dump_key);
|
||||
}
|
||||
}
|
||||
+ count_time -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/python/sentryCollector/collect_io.py b/src/python/sentryCollector/collect_io.py
|
||||
index 9c6bbc9..8a82eab 100644
|
||||
--- a/src/python/sentryCollector/collect_io.py
|
||||
+++ b/src/python/sentryCollector/collect_io.py
|
||||
@@ -387,7 +387,7 @@ class CollectIo():
|
||||
curr_io_dump_count: int,
|
||||
prev_io_dump_count: int
|
||||
) -> Union[int, float]:
|
||||
- io_dump_count = curr_io_dump_count - prev_io_dump_count
|
||||
+ io_dump_count = curr_io_dump_count
|
||||
if io_dump_count <= 0:
|
||||
return 0
|
||||
value = io_dump_count
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
Summary: System Inspection Framework
|
||||
Name: sysSentry
|
||||
Version: 1.0.2
|
||||
Release: 50
|
||||
Release: 51
|
||||
License: Mulan PSL v2
|
||||
Group: System Environment/Daemons
|
||||
Source0: https://gitee.com/openeuler/sysSentry/releases/download/v%{version}/%{name}-%{version}.tar.gz
|
||||
@ -67,6 +67,7 @@ Patch54: fix-ai_block_io-root-cause-bug.patch
|
||||
Patch55: ebpf-fix-kyqin-miss-rq_driver-data.patch
|
||||
Patch56: optimize-log-printing.patch
|
||||
Patch57: enrich-alert-info-about-kernel-stack.patch
|
||||
Patch58: ebpf-fix-iodump-warning.patch
|
||||
|
||||
BuildRequires: cmake gcc-c++
|
||||
BuildRequires: python3 python3-setuptools
|
||||
@ -339,6 +340,12 @@ rm -rf %{buildroot}
|
||||
%attr(0550,root,root) %{python3_sitelib}/sentryCollector/__pycache__/collect_plugin*
|
||||
|
||||
%changelog
|
||||
* Wed Oct 16 2024 zhangnan <zhangnan134@huawei.com> - 1.0.2-51
|
||||
- Type:bugfix
|
||||
- CVE:NA
|
||||
- SUG:NA
|
||||
- DES:fix ebpf iodump warning
|
||||
|
||||
* Wed Oct 16 2024 heyouzhi <heyouzhi@huawei.com> - 1.0.2-50
|
||||
- Type:bugfix
|
||||
- CVE:NA
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user