!122 修复xalarm日志格式打印不统一问题
From: @pshysimon Reviewed-by: @hubin95 Signed-off-by: @hubin95
This commit is contained in:
commit
b9ce9826f7
60
fix-xalarm-non-uniform-log-formatting.patch
Normal file
60
fix-xalarm-non-uniform-log-formatting.patch
Normal file
@ -0,0 +1,60 @@
|
||||
From 3eba5dcde10e05e7badc99852f76488e667d56e6 Mon Sep 17 00:00:00 2001
|
||||
From: caixiaomeng <caixiaomeng2@.com>
|
||||
Date: Mon, 21 Oct 2024 11:57:37 +0800
|
||||
Subject: [PATCH] fix xalarm non-uniform log formatting
|
||||
|
||||
---
|
||||
src/python/xalarm/sentry_notify.py | 11 ++++++-----
|
||||
1 file changed, 6 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/src/python/xalarm/sentry_notify.py b/src/python/xalarm/sentry_notify.py
|
||||
index 5838473..ffe4147 100644
|
||||
--- a/src/python/xalarm/sentry_notify.py
|
||||
+++ b/src/python/xalarm/sentry_notify.py
|
||||
@@ -2,6 +2,7 @@ import os
|
||||
import sys
|
||||
import time
|
||||
import socket
|
||||
+import logging
|
||||
from struct import error as StructParseError
|
||||
|
||||
from .xalarm_api import alarm_stu2bin, Xalarm
|
||||
@@ -27,21 +28,21 @@ ALARM_SOCKET_PERMISSION = 0o700
|
||||
|
||||
def check_params(alarm_id, alarm_level, alarm_type, puc_paras) -> bool:
|
||||
if not os.path.exists(DIR_XALARM):
|
||||
- sys.stderr.write(f"check_params: {DIR_XALARM} not exist, failed\n")
|
||||
+ logging.error(f"check_params: {DIR_XALARM} not exist, failed")
|
||||
return False
|
||||
|
||||
if not os.path.exists(PATH_REPORT_ALARM):
|
||||
- sys.stderr.write(f"check_params: {PATH_REPORT_ALARM} not exist, failed\n")
|
||||
+ logging.error(f"check_params: {PATH_REPORT_ALARM} not exist, failed")
|
||||
return False
|
||||
|
||||
if (alarm_id < MIN_ALARM_ID or alarm_id > MAX_ALARM_ID or
|
||||
alarm_level < MINOR_ALM or alarm_level > CRITICAL_ALM or
|
||||
alarm_type < ALARM_TYPE_OCCUR or alarm_type > ALARM_TYPE_RECOVER):
|
||||
- sys.stderr.write("check_params: alarm info invalid\n")
|
||||
+ logging.error("check_params: alarm info invalid")
|
||||
return False
|
||||
|
||||
if len(puc_paras) >= MAX_PUC_PARAS_LEN:
|
||||
- sys.stderr.write(f"check_params: alarm msg should be less than {MAX_PUC_PARAS_LEN}\n")
|
||||
+ logging.error(f"check_params: alarm msg should be less than {MAX_PUC_PARAS_LEN}")
|
||||
return False
|
||||
|
||||
return True
|
||||
@@ -61,7 +62,7 @@ def xalarm_report(alarm_id, alarm_level, alarm_type, puc_paras) -> bool:
|
||||
|
||||
sock.sendto(alarm_stu2bin(alarm_info), PATH_REPORT_ALARM)
|
||||
except (FileNotFoundError, StructParseError, socket.error, OSError, UnicodeError) as e:
|
||||
- sys.stderr.write(f"check_params: error occurs when sending msg.{e}\n")
|
||||
+ logging.error(f"error occurs when sending msg.")
|
||||
return False
|
||||
finally:
|
||||
sock.close()
|
||||
--
|
||||
2.27.0
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
Summary: System Inspection Framework
|
||||
Name: sysSentry
|
||||
Version: 1.0.2
|
||||
Release: 44
|
||||
Release: 45
|
||||
License: Mulan PSL v2
|
||||
Group: System Environment/Daemons
|
||||
Source0: https://gitee.com/openeuler/sysSentry/releases/download/v%{version}/%{name}-%{version}.tar.gz
|
||||
@ -65,6 +65,7 @@ Patch52: fix-word-error.patch
|
||||
Patch53: optimize-log-printing.patch
|
||||
Patch54: enrich-alert-info-about-kernel-stack.patch
|
||||
Patch55: ai_block_io-lack-section-exit.patch
|
||||
Patch56: fix-xalarm-non-uniform-log-formatting.patch
|
||||
|
||||
BuildRequires: cmake gcc-c++
|
||||
BuildRequires: python3 python3-setuptools
|
||||
@ -327,6 +328,12 @@ rm -rf %{buildroot}
|
||||
%attr(0550,root,root) %{python3_sitelib}/sentryCollector/__pycache__/collect_plugin*
|
||||
|
||||
%changelog
|
||||
* Mon Oct 21 2024 caixiaomeng <caixiaomeng2@huawei.com> - 1.0.2-45
|
||||
- Type:bugfix
|
||||
- CVE:NA
|
||||
- SUG:NA
|
||||
- DESC:ai_block_io lack section exit
|
||||
|
||||
* Mon Oct 21 2024 heyouzhi <heyouzhi@huawei.com> - 1.0.2-44
|
||||
- Type:bugfix
|
||||
- CVE:NA
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user