!63 fix get_alarm length and timestamp
From: @boluo56 Reviewed-by: @hubin95 Signed-off-by: @hubin95
This commit is contained in:
commit
24a6c458fc
32
add-detail-time.patch
Normal file
32
add-detail-time.patch
Normal file
@ -0,0 +1,32 @@
|
||||
From 9ecd4c2c9c9f9578f5ec4780360dc67b182b384a Mon Sep 17 00:00:00 2001
|
||||
From: jinsaihang <jinsaihang@h-partners.com>
|
||||
Date: Wed, 9 Oct 2024 08:09:04 +0000
|
||||
Subject: [PATCH 2/2] add detail time
|
||||
|
||||
Signed-off-by: jinsaihang <jinsaihang@h-partners.com>
|
||||
---
|
||||
src/python/syssentry/alarm.py | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/python/syssentry/alarm.py b/src/python/syssentry/alarm.py
|
||||
index 74a2716..d5337d3 100644
|
||||
--- a/src/python/syssentry/alarm.py
|
||||
+++ b/src/python/syssentry/alarm.py
|
||||
@@ -118,11 +118,13 @@ def get_alarm_result(task_name: str, time_range: int, detailed: bool) -> List[Di
|
||||
logging.debug(f"get_alarm_result: final alarm_list of {alarm_id} has {len(alarm_list)} elements")
|
||||
|
||||
def xalarm_to_dict(alarm_info: Xalarm) -> dict:
|
||||
+ timestamp = alarm_info.timetamp.tv_sec + alarm_info.timetamp.tv_usec / 1000000
|
||||
+ dt_object = datetime.fromtimestamp(int(timestamp))
|
||||
return {
|
||||
'alarm_id': xalarm_getid(alarm_info),
|
||||
'alarm_type': xalarm_gettype(alarm_info),
|
||||
'alarm_level': xalarm_getlevel(alarm_info),
|
||||
- 'timetamp': xalarm_gettime(alarm_info),
|
||||
+ 'timestamp': dt_object.strftime("%Y-%m-%d %H:%M:%S"),
|
||||
'msg1': xalarm_getdesc(alarm_info)
|
||||
}
|
||||
|
||||
--
|
||||
2.27.0
|
||||
|
||||
56
change-alarm-length.patch
Normal file
56
change-alarm-length.patch
Normal file
@ -0,0 +1,56 @@
|
||||
From 67439c0040b1fb0614ac009bf53062e9ec2880aa Mon Sep 17 00:00:00 2001
|
||||
From: jinsaihang <jinsaihang@h-partners.com>
|
||||
Date: Wed, 9 Oct 2024 11:55:35 +0800
|
||||
Subject: [PATCH 1/2] change alarm length
|
||||
|
||||
Signed-off-by: jinsaihang <jinsaihang@h-partners.com>
|
||||
---
|
||||
src/python/syssentry/sentryctl | 3 +++
|
||||
src/python/syssentry/syssentry.py | 3 +++
|
||||
2 files changed, 6 insertions(+)
|
||||
|
||||
diff --git a/src/python/syssentry/sentryctl b/src/python/syssentry/sentryctl
|
||||
index 675c17a..3de93d0 100644
|
||||
--- a/src/python/syssentry/sentryctl
|
||||
+++ b/src/python/syssentry/sentryctl
|
||||
@@ -25,6 +25,7 @@ MAX_PARAM_LENGTH = 256
|
||||
|
||||
RESULT_MSG_DATA_LEN = 4
|
||||
CTL_MSG_LEN_LEN = 3
|
||||
+ALARM_MSG_DATA_LEN = 6
|
||||
DEFAULT_ALARM_TIME_RANGE = 10
|
||||
|
||||
def status_output_format(res_data):
|
||||
@@ -173,6 +174,8 @@ if __name__ == '__main__':
|
||||
request_message = json.dumps(req_msg_struct)
|
||||
if client_args.cmd_type == 'get_result':
|
||||
result_message = client_send_and_recv(request_message, RESULT_MSG_DATA_LEN)
|
||||
+ elif client_args.cmd_type == 'get_alarm':
|
||||
+ result_message = client_send_and_recv(request_message, ALARM_MSG_DATA_LEN)
|
||||
else:
|
||||
result_message = client_send_and_recv(request_message, CTL_MSG_LEN_LEN)
|
||||
if not result_message:
|
||||
diff --git a/src/python/syssentry/syssentry.py b/src/python/syssentry/syssentry.py
|
||||
index c2dee85..ea09095 100644
|
||||
--- a/src/python/syssentry/syssentry.py
|
||||
+++ b/src/python/syssentry/syssentry.py
|
||||
@@ -56,6 +56,7 @@ CTL_MSG_MAGIC_LEN = 3
|
||||
CTL_MSG_LEN_LEN = 3
|
||||
CTL_MAGIC = "CTL"
|
||||
RES_MAGIC = "RES"
|
||||
+ALARM_MSG_DATA_LEN = 6
|
||||
|
||||
CTL_LISTEN_QUEUE_LEN = 5
|
||||
SERVER_EPOLL_TIMEOUT = 0.3
|
||||
@@ -256,6 +257,8 @@ def server_recv(server_socket: socket.socket):
|
||||
res_head = RES_MAGIC
|
||||
if cmd_type == "get_result":
|
||||
res_data_len = str(len(res_data)).zfill(RESULT_MSG_HEAD_LEN - RESULT_MSG_MAGIC_LEN)
|
||||
+ elif cmd_type == "get_alarm":
|
||||
+ res_data_len = str(len(res_data)).zfill(ALARM_MSG_DATA_LEN)
|
||||
else:
|
||||
res_data_len = str(len(res_data)).zfill(CTL_MSG_MAGIC_LEN)
|
||||
res_head += res_data_len
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
Summary: System Inspection Framework
|
||||
Name: sysSentry
|
||||
Version: 1.0.2
|
||||
Release: 25
|
||||
Release: 26
|
||||
License: Mulan PSL v2
|
||||
Group: System Environment/Daemons
|
||||
Source0: https://gitee.com/openeuler/sysSentry/releases/download/v%{version}/%{name}-%{version}.tar.gz
|
||||
@ -38,6 +38,8 @@ Patch25: avg_block_io-send-alarm-to-xalarmd.patch
|
||||
Patch26: bugfix-typo.patch
|
||||
Patch27: fix-config-relative-some-issues.patch
|
||||
Patch28: update-log-when-it-is-not-lock-collect.patch
|
||||
Patch29: change-alarm-length.patch
|
||||
Patch30: add-detail-time.patch
|
||||
|
||||
BuildRequires: cmake gcc-c++
|
||||
BuildRequires: python3 python3-setuptools
|
||||
@ -280,6 +282,12 @@ rm -rf %{buildroot}
|
||||
%attr(0550,root,root) %{python3_sitelib}/sentryPlugins/ai_block_io
|
||||
|
||||
%changelog
|
||||
* Thu Oct 10 2024 jinsaihang <jinsaihang@h-partners.com> - 1.0.2-26
|
||||
- Type:bugfix
|
||||
- CVE:NA
|
||||
- SUG:NA
|
||||
- DESC:fix get_alarm length and timestamp
|
||||
|
||||
* Wed Oct 9 2024 zhuofeng <zhuofeng2@huawei.com> - 1.0.2-25
|
||||
- Type:bugfix
|
||||
- CVE:NA
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user