Module: check_mk
Branch: master
Commit: a5d76812199aac25af13ac98707064da642af9ef
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a5d76812199aac…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Jul 13 12:27:14 2017 +0200
EC: Logging can now be configured with finer granularity
Change-Id: I7243eae8419774e2d2e3f23f4ccd7b5e76170ca7
---
bin/mkeventd | 25 ++++++++++++++++++---
web/htdocs/wato.py | 2 +-
web/plugins/wato/mkeventd.py | 53 +++++++++++++++++++++++++++++++++++---------
3 files changed, 66 insertions(+), 14 deletions(-)
diff --git a/bin/mkeventd b/bin/mkeventd
index 69af468..17a0aeb 100755
--- a/bin/mkeventd
+++ b/bin/mkeventd
@@ -602,6 +602,7 @@ class HostConfig(object):
def _set_logger(self):
self.logger = logger.getChild("HostConfig")
+
#self.logger.setLevel(g_config["log_level"]["cmk.mkeventd.HostConfig"])
def initialize(self):
@@ -1276,6 +1277,7 @@ class EventServer(object):
def _set_logger(self):
self.logger = logger.getChild("EventServer")
+
self.logger.setLevel(g_config["log_level"]["cmk.mkeventd.EventServer"])
def status_columns(self):
@@ -3096,6 +3098,7 @@ class StatusServer(object):
def _set_logger(self):
self.logger = logger.getChild("StatusServer")
+
self.logger.setLevel(g_config["log_level"]["cmk.mkeventd.StatusServer"])
def open_sockets(self):
@@ -3655,6 +3658,7 @@ class EventStatus(object):
def _set_logger(self):
self.logger = logger.getChild("EventStatus")
+
self.logger.setLevel(g_config["log_level"]["cmk.mkeventd.EventStatus"])
def flush(self):
@@ -4711,9 +4715,19 @@ def load_configuration():
execfile(path, g_config, g_config)
# If not set by command line, set the log level by configuration
- # TODO: Change EC log level configuration to new cmk standard log levels
if opt_verbose == 0:
- cmk.log.set_verbosity(g_config["log_level"])
+ # Transform old normal/verbose config
+ if g_config["log_level"] in (0, 1):
+ log_level = cmk.log.INFO if g_config["log_level"] == 0 else
cmk.log.VERBOSE
+
+ g_config["log_level"] = {
+ "cmk.mkeventd" : log_level,
+ "cmk.mkeventd.EventServer" : log_level,
+ "cmk.mkeventd.EventStatus" : log_level,
+ "cmk.mkeventd.StatusServer" : log_level,
+ }
+
+ logger.setLevel(g_config["log_level"]["cmk.mkeventd"])
# Configure the auto deleting indexes in the DB when mongodb is enabled
if g_config['archive_mode'] == 'mongodb':
@@ -4753,7 +4767,12 @@ def default_config():
"actions" : [],
"debug_rules" : False,
"rule_optimizer" : True,
- "log_level" : 0,
+ "log_level" : {
+ "cmk.mkeventd" : cmk.log.INFO,
+ "cmk.mkeventd.EventServer" : cmk.log.INFO,
+ "cmk.mkeventd.EventStatus" : cmk.log.INFO,
+ "cmk.mkeventd.StatusServer" : cmk.log.INFO,
+ },
"log_rulehits" : False,
"log_messages" : False,
"retention_interval" : 60,
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 4dd6177..9dbeb19 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -16667,7 +16667,7 @@ def is_a_checkbox(vs):
def site_neutral_path(path):
if path.startswith('/omd'):
parts = path.split('/')
- parts[3] = '<siteid>'
+ parts[3] = '[SITE_ID]'
return '/'.join(parts)
else:
return path
diff --git a/web/plugins/wato/mkeventd.py b/web/plugins/wato/mkeventd.py
index 505818b..f77e30a 100644
--- a/web/plugins/wato/mkeventd.py
+++ b/web/plugins/wato/mkeventd.py
@@ -2756,18 +2756,51 @@ if mkeventd_enabled:
domain = ConfigDomainEventConsole,
)
+ def ec_log_level_elements():
+ elements = []
+
+ for component, title, help_txt in [
+ ("cmk.mkeventd", _("General messages"),
+ _("Log level for all log messages that are not in one of the
categories below")),
+ ("cmk.mkeventd.EventServer", _("Processing of incoming
events"),
+ _("Log level for the processing of all incoming events")),
+ ("cmk.mkeventd.EventStatus", _("Event database"),
+ _("Log level for managing already created events")),
+ ("cmk.mkeventd.StatusServer", _("Status queries"),
+ _("Log level for handling of incoming queries to the status
socket")),
+ ]:
+ elements.append(
+ (component, DropdownChoice(
+ title = title,
+ help = help_txt,
+ choices = [
+ (cmk.log.CRITICAL, _("Critical") ),
+ (cmk.log.ERROR, _("Error") ),
+ (cmk.log.WARNING, _("Warning") ),
+ (cmk.log.INFO, _("Informational") ),
+ (cmk.log.VERBOSE, _("Verbose") ),
+ (cmk.log.DEBUG, _("Debug") ),
+ ],
+ default_value = cmk.log.INFO,
+ ))
+ )
+ return elements
+
register_configvar(groups["ec_log"],
"log_level",
- DropdownChoice(
- title = _("Log level"),
- help = _("You can configure the Event Console to log more details about
it's actions. "
- "These information are logged into the file
<tt>%s</tt>") %
- site_neutral_path(cmk.paths.log_dir +
"/mkeventd.log"),
- choices = [
- (0, _("Normal logging")),
- (1, _("Verbose logging")),
- ],
- default_value = 0,
+ Transform(
+ Dictionary(
+ title = _("Log level"),
+ help = _("You can configure the Event Console to log more details
about it's actions. "
+ "These information are logged into the file
<tt>%s</tt>") %
+ site_neutral_path(cmk.paths.log_dir +
"/mkeventd.log"),
+ elements = ec_log_level_elements,
+ optional_keys = [],
+ ),
+ # Transform old values:
+ # 0 -> normal logging
+ # 1 -> verbose logging
+ forth=lambda x: {"cmk.mkeventd": (cmk.log.INFO if x == 0 else
cmk.log.VERBOSE)} if x in (0, 1) else x,
),
domain = ConfigDomainEventConsole,
)