!171 fix bug: when ai_threshold update, absolute threshold not be used.

From: @hyz2024 
Reviewed-by: @znzjugod 
Signed-off-by: @znzjugod
This commit is contained in:
openeuler-ci-bot 2024-11-16 01:54:33 +00:00 committed by Gitee
commit 73514a1653
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 64 additions and 1 deletions

View File

@ -0,0 +1,56 @@
From 11483f4efe29ac971379f845078701f44b430682 Mon Sep 17 00:00:00 2001
From: Youzhi He <heyouzhi@huawei.com>
Date: Fri, 15 Nov 2024 17:34:35 +0800
Subject: [PATCH] fix when ai threshold update but absolute threshold not be
used
---
.../ai_block_io/sliding_window.py | 20 +++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/python/sentryPlugins/ai_block_io/sliding_window.py b/src/python/sentryPlugins/ai_block_io/sliding_window.py
index ff3fa3b..a13033f 100644
--- a/src/python/sentryPlugins/ai_block_io/sliding_window.py
+++ b/src/python/sentryPlugins/ai_block_io/sliding_window.py
@@ -30,20 +30,20 @@ class SlidingWindow:
self._io_data_queue = []
self._io_data_queue_abnormal_tag = []
+ def is_abnormal(self, data):
+ if self._avg_lim is not None and data < self._avg_lim:
+ return False
+ if self._ai_threshold is not None and data > self._ai_threshold:
+ return True
+ if self._abs_threshold is not None and data > self._abs_threshold:
+ return True
+
def push(self, data: float):
if len(self._io_data_queue) == self._queue_length:
self._io_data_queue.pop(0)
self._io_data_queue_abnormal_tag.pop(0)
self._io_data_queue.append(data)
- tag = False
- if self._avg_lim is not None and data < self._avg_lim:
- tag = False
- self._io_data_queue_abnormal_tag.append(tag)
- return tag
- if self._ai_threshold is not None and data > self._ai_threshold:
- tag = True
- if self._abs_threshold is not None and data > self._abs_threshold:
- tag = True
+ tag = self.is_abnormal(data)
self._io_data_queue_abnormal_tag.append(tag)
return tag
@@ -53,7 +53,7 @@ class SlidingWindow:
self._ai_threshold = threshold
self._io_data_queue_abnormal_tag.clear()
for data in self._io_data_queue:
- self._io_data_queue_abnormal_tag.append(data >= self._ai_threshold)
+ self._io_data_queue_abnormal_tag.append(self.is_abnormal(data))
def is_slow_io_event(self, data):
return False, None, None, None
--
2.27.0

View File

@ -4,7 +4,7 @@
Summary: System Inspection Framework
Name: sysSentry
Version: 1.0.2
Release: 66
Release: 67
License: Mulan PSL v2
Group: System Environment/Daemons
Source0: https://gitee.com/openeuler/sysSentry/releases/download/v%{version}/%{name}-%{version}.tar.gz
@ -82,6 +82,7 @@ Patch69: modify-logrotate-rule.patch
Patch70: fix-excessive-CPU-usage.patch
Patch71: change-avg_block_io-config.patch
Patch72: update-nvme-config.patch
Patch73: fix-absolute-threshold-not-be-used.patch
BuildRequires: cmake gcc-c++
BuildRequires: python3 python3-setuptools
@ -353,6 +354,12 @@ rm -rf %{buildroot}
%attr(0550,root,root) %{python3_sitelib}/sentryCollector/__pycache__/collect_plugin*
%changelog
* Fri Nov 15 2024 heyouzhi <heyouzhi@huawei.com> - 1.0.2-67
- Type:bugfix
- CVE:NA
- SUG:NA
- DESC:fix absolute threshold not be used
* Tue Nov 5 2024 zhangnan <zhangnan134@huawei.com> - 1.0.2-66
- Type:bugfix
- CVE:NA