update the log level of sysSentry
This commit is contained in:
parent
a7ff7d362f
commit
366073cb31
@ -4,7 +4,7 @@
|
||||
Summary: System Inspection Framework
|
||||
Name: sysSentry
|
||||
Version: 1.0.2
|
||||
Release: 19
|
||||
Release: 20
|
||||
License: Mulan PSL v2
|
||||
Group: System Environment/Daemons
|
||||
Source0: https://gitee.com/openeuler/sysSentry/releases/download/v%{version}/%{name}-%{version}.tar.gz
|
||||
@ -30,6 +30,7 @@ Patch17: add-hbm-online-repair.patch
|
||||
Patch18: fix-hbm-online-repair-notice-and-efi-create.patch
|
||||
Patch19: fix-uint8-bug-and-change-isolation-default-value.patch
|
||||
Patch20: fix-write-file-return-code-bug.patch
|
||||
Patch21: update-the-commit-of-the-log-level-and-format-of-sys.patch
|
||||
|
||||
BuildRequires: cmake gcc-c++
|
||||
BuildRequires: python3 python3-setuptools
|
||||
@ -219,6 +220,12 @@ rm -rf %{buildroot}
|
||||
%attr(0550,root,root) %{python3_sitelib}/syssentry/bmc_alarm.py
|
||||
|
||||
%changelog
|
||||
* Tue Nov 5 2024 luckky <guodashun1@huawei.com> - 1.0.2-20
|
||||
- Type:enhancement
|
||||
- CVE:NA
|
||||
- SUG:NA
|
||||
- DESC: update the commit of the log level and format function of sysSentry
|
||||
|
||||
* Mon Nov 4 2024 luckky <guodashun1@huawei.com> - 1.0.2-19
|
||||
- Type:bugfix
|
||||
- CVE:NA
|
||||
|
||||
172
update-the-commit-of-the-log-level-and-format-of-sys.patch
Normal file
172
update-the-commit-of-the-log-level-and-format-of-sys.patch
Normal file
@ -0,0 +1,172 @@
|
||||
From 273ef60bd4263add69c1171202c9804d40a992ea Mon Sep 17 00:00:00 2001
|
||||
From: luckky <guodashun1@huawei.com>
|
||||
Date: Tue, 5 Nov 2024 18:53:49 +0800
|
||||
Subject: [PATCH] update the commit of the log level and format of syssentry
|
||||
|
||||
---
|
||||
config/inspect.conf | 5 +++-
|
||||
config/tasks/hbm_online_repair.mod | 2 +-
|
||||
src/c/hbm_online_repair/hbm_online_repair.c | 8 +++---
|
||||
src/python/syssentry/sentry_config.py | 28 +++++++++++++++++++++
|
||||
src/python/syssentry/syssentry.py | 16 +++++++-----
|
||||
5 files changed, 47 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/config/inspect.conf b/config/inspect.conf
|
||||
index 071cca1..f451d9e 100644
|
||||
--- a/config/inspect.conf
|
||||
+++ b/config/inspect.conf
|
||||
@@ -1,2 +1,5 @@
|
||||
[inspect]
|
||||
-Interval=3
|
||||
\ No newline at end of file
|
||||
+Interval=3
|
||||
+
|
||||
+[log]
|
||||
+level=info
|
||||
diff --git a/config/tasks/hbm_online_repair.mod b/config/tasks/hbm_online_repair.mod
|
||||
index 77dd73e..4dcef43 100644
|
||||
--- a/config/tasks/hbm_online_repair.mod
|
||||
+++ b/config/tasks/hbm_online_repair.mod
|
||||
@@ -3,7 +3,7 @@ enabled=yes
|
||||
task_start=/usr/bin/hbm_online_repair
|
||||
task_stop=kill $pid
|
||||
type=period
|
||||
-interval=180
|
||||
+interval=10
|
||||
onstart=yes
|
||||
env_file=/etc/sysconfig/hbm_online_repair.env
|
||||
conflict=up
|
||||
\ No newline at end of file
|
||||
diff --git a/src/c/hbm_online_repair/hbm_online_repair.c b/src/c/hbm_online_repair/hbm_online_repair.c
|
||||
index b3b2742..943f201 100644
|
||||
--- a/src/c/hbm_online_repair/hbm_online_repair.c
|
||||
+++ b/src/c/hbm_online_repair/hbm_online_repair.c
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "non-standard-hbm-repair.h"
|
||||
|
||||
#define DEFAULT_LOG_LEVEL LOG_INFO
|
||||
-#define DEFAULT_PAGE_ISOLATION_THRESHOLD 128
|
||||
+#define DEFAULT_PAGE_ISOLATION_THRESHOLD 3355443
|
||||
|
||||
int global_level_setting;
|
||||
int page_isolation_threshold;
|
||||
@@ -44,7 +44,7 @@ int execute_command(const char *command)
|
||||
}
|
||||
|
||||
fgets(buffer, sizeof(buffer), fp);
|
||||
- log(LOG_DEBUG, "output of command is: %s\n", buffer);
|
||||
+ log(LOG_DEBUG, "output of command %s is: %s\n", command, buffer);
|
||||
|
||||
ret = pclose(fp);
|
||||
if (ret < 0) {
|
||||
@@ -53,12 +53,12 @@ int execute_command(const char *command)
|
||||
}
|
||||
|
||||
if (!WIFEXITED(ret)) {
|
||||
- log(LOG_ERROR, "command did not terminate normally\n");
|
||||
+ log(LOG_ERROR, "command %s did not terminate normally\n", command);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = WEXITSTATUS(ret);
|
||||
- log(LOG_DEBUG, "command exited with status: %d\n", ret);
|
||||
+ log(LOG_DEBUG, "command %s exited with status: %d\n", command, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
diff --git a/src/python/syssentry/sentry_config.py b/src/python/syssentry/sentry_config.py
|
||||
index a0e7b79..1169887 100644
|
||||
--- a/src/python/syssentry/sentry_config.py
|
||||
+++ b/src/python/syssentry/sentry_config.py
|
||||
@@ -21,6 +21,34 @@ import sys
|
||||
DEFAULT_INSPECT_DELAY = 3
|
||||
INSPECT_CONF_PATH = "/etc/sysSentry/inspect.conf"
|
||||
|
||||
+CONF_LOG = 'log'
|
||||
+CONF_LOG_LEVEL = 'level'
|
||||
+LogLevel = {
|
||||
+ "debug": logging.DEBUG,
|
||||
+ "info": logging.INFO,
|
||||
+ "warning": logging.WARNING,
|
||||
+ "error": logging.ERROR,
|
||||
+ "critical": logging.CRITICAL
|
||||
+}
|
||||
+
|
||||
+
|
||||
+def get_log_level(filename=INSPECT_CONF_PATH):
|
||||
+ if not os.path.exists(filename):
|
||||
+ return logging.INFO
|
||||
+
|
||||
+ try:
|
||||
+ config = configparser.ConfigParser()
|
||||
+ config.read(filename)
|
||||
+ if not config.has_option(CONF_LOG, CONF_LOG_LEVEL):
|
||||
+ return logging.INFO
|
||||
+ log_level = config.get(CONF_LOG, CONF_LOG_LEVEL)
|
||||
+
|
||||
+ if log_level.lower() in LogLevel:
|
||||
+ return LogLevel.get(log_level.lower())
|
||||
+ return logging.INFO
|
||||
+ except configparser.Error:
|
||||
+ return logging.INFO
|
||||
+
|
||||
|
||||
class SentryConfig:
|
||||
"""
|
||||
diff --git a/src/python/syssentry/syssentry.py b/src/python/syssentry/syssentry.py
|
||||
index debff4e..0956e1e 100644
|
||||
--- a/src/python/syssentry/syssentry.py
|
||||
+++ b/src/python/syssentry/syssentry.py
|
||||
@@ -23,7 +23,7 @@ import fcntl
|
||||
|
||||
import select
|
||||
|
||||
-from .sentry_config import SentryConfig
|
||||
+from .sentry_config import SentryConfig, get_log_level
|
||||
|
||||
from .task_map import TasksMap
|
||||
from .global_values import SENTRY_RUN_DIR, CTL_SOCKET_PATH, SENTRY_RUN_DIR_PERM
|
||||
@@ -112,15 +112,16 @@ def msg_data_process(msg_data):
|
||||
|
||||
cmd_type = data_struct['type']
|
||||
if cmd_type not in type_func and cmd_type not in type_func_void:
|
||||
- logging.error("recv invaild cmd type: %s", cmd_type)
|
||||
- return "Invaild cmd type"
|
||||
+ logging.error("recv invalid cmd type: %s", cmd_type)
|
||||
+ return "Invalid cmd type"
|
||||
|
||||
cmd_param = data_struct['data']
|
||||
- logging.debug("msg_data_process cmd_type:%s cmd_param:%s", cmd_type, cmd_param)
|
||||
+ logging.debug("msg_data_process cmd_type:%s cmd_param:%s", cmd_type, str(cmd_param))
|
||||
if cmd_type in type_func:
|
||||
ret, res_data = type_func[cmd_type](cmd_param)
|
||||
else:
|
||||
ret, res_data = type_func_void[cmd_type]()
|
||||
+ logging.debug("msg_data_process res_data:%s",str(res_data))
|
||||
res_msg_struct = {"ret": ret, "data": res_data}
|
||||
res_msg = json.dumps(res_msg_struct)
|
||||
|
||||
@@ -414,7 +415,7 @@ def server_result_recv(server_socket: socket.socket):
|
||||
try:
|
||||
client_socket.send(process_plugins_result.encode())
|
||||
except OSError:
|
||||
- logging.warning("server send reponse to plugins failed")
|
||||
+ logging.warning("server send response to plugins failed")
|
||||
finally:
|
||||
client_socket.close()
|
||||
return
|
||||
@@ -621,7 +622,10 @@ def main():
|
||||
os.mkdir(SENTRY_RUN_DIR)
|
||||
os.chmod(SENTRY_RUN_DIR, mode=SENTRY_RUN_DIR_PERM)
|
||||
|
||||
- logging.basicConfig(filename=SYSSENTRY_LOG_FILE, level=logging.INFO)
|
||||
+ log_level = get_log_level()
|
||||
+ log_format = "%(asctime)s - %(levelname)s - [%(filename)s:%(lineno)d] - %(message)s"
|
||||
+
|
||||
+ logging.basicConfig(filename=SYSSENTRY_LOG_FILE, level=log_level, format=log_format)
|
||||
os.chmod(SYSSENTRY_LOG_FILE, 0o600)
|
||||
|
||||
if not chk_and_set_pidfile():
|
||||
--
|
||||
2.43.0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user