Module: check_mk
Branch: master
Commit: 2e09cbbefab998a28eb19fb77706a4d97bfa9d70
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2e09cbbefab998…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Mar 27 09:55:39 2019 +0100
7329 FIX Deprecate logwatch_patterns configuration option
If you have always used WATO to configure your Check_MK you are not affected
by this change.
There have been two configuration options for configuring logwatch pattern on
Check_MK server side rules for a long time. The old one,
<tt>logwatch_patterns</tt>, and the newer WATO compatible ruleset
<tt>logwatch_rules</tt>. The second one has replaced the first one a long
time
ago. The old config optionswas still working for compatibility but has been
removed now.
If you have configured such rules in your configuration, it will still load,
but print out a warning message like this: "WARNING: Found rules for deprecated
ruleset 'logwatch_patterns'. These rules are not applied anymore. In case you
still need them, you need to migrate them by hand. Otherwise you can remove
them from your configuration."
Change-Id: Iaa97c79745cbf1014cca025582757c5700ba8029
---
.werks/7329 | 24 ++++++++++++++++++++++++
checks/logwatch | 46 +++++-----------------------------------------
cmk_base/check_api.py | 9 +++++++--
cmk_base/config.py | 1 +
4 files changed, 37 insertions(+), 43 deletions(-)
diff --git a/.werks/7329 b/.werks/7329
new file mode 100644
index 0000000..ecd0e05
--- /dev/null
+++ b/.werks/7329
@@ -0,0 +1,24 @@
+Title: Deprecate logwatch_patterns configuration option
+Level: 1
+Component: checks
+Compatible: incomp
+Edition: cre
+Version: 1.6.0i1
+Date: 1553676821
+Class: fix
+
+If you have always used WATO to configure your Check_MK you are not affected
+by this change.
+
+There have been two configuration options for configuring logwatch pattern on
+Check_MK server side rules for a long time. The old one,
+<tt>logwatch_patterns</tt>, and the newer WATO compatible ruleset
+<tt>logwatch_rules</tt>. The second one has replaced the first one a long
time
+ago. The old config optionswas still working for compatibility but has been
+removed now.
+
+If you have configured such rules in your configuration, it will still load,
+but print out a warning message like this: "WARNING: Found rules for deprecated
+ruleset 'logwatch_patterns'. These rules are not applied anymore. In case you
+still need them, you need to migrate them by hand. Otherwise you can remove
+them from your configuration."
diff --git a/checks/logwatch b/checks/logwatch
index a9b9c26..7c4adbd 100644
--- a/checks/logwatch
+++ b/checks/logwatch
@@ -30,12 +30,15 @@ import cmk.utils.debug
# Configuration variables in main.mk needed during the actual check
logwatch_dir = cmk.utils.paths.var_dir + '/logwatch'
-logwatch_patterns = {}
logwatch_rules = []
logwatch_max_filesize = 500000 # do not save more than 500k of message (configurable)
logwatch_service_output = "default"
logwatch_groups = []
+# Deprecated option since 1.6. cmk_base creates a config warning when finding rules
+# for this ruleset. Can be dropped with 1.7.
+logwatch_patterns = {}
+
# Variables embedded in precompiled checks
check_config_variables += ["logwatch_dir", "logwatch_max_filesize",
"logwatch_service_output"]
@@ -95,20 +98,6 @@ def logwatch_select_forwarded(info):
return forwarded_logs, not_forwarded_logs
-# logwatch_patterns = {
-# 'System': [
-# ( 'W', 'sshd' ),
-# ( ['host1', 'host2'], 'C', 'ssh' ), # only
applies to certain hosts
-# ( ['lnx', 'dmz'], ALL_HOSTS, 'C', 'ssh' ), # only
applies to host having certain tags
-# ( ALL_HOSTS, (10, 20), 'x' ), # at 10 messages per interval warn, at 20
crit
-# ( 'I', '0' )
-# ],
-# 'Application': [
-# ( 'W', 'crash.exe' ),
-# ( 'E', 'ssh' )
-# ]
-# }
-
# New rule-stule logwatch_rules in WATO friendly consistent rule notation:
#
# logwatch_rules = [
@@ -179,31 +168,6 @@ def logwatch_precompile(hostname, item, _unused):
else:
params["reclassify_patterns"].extend(x for x in rule)
- # Now load the old logwatch_patterns var
- patterns = logwatch_patterns.get(item)
- if patterns:
- for entry in patterns:
- hostlist = None
- tags = []
-
- pattern = entry[-1]
- level = entry[-2]
-
- if len(entry) >= 3: # found optional host list
- hostlist = entry[-3]
- if len(entry) >= 4: # found optional host tags
- tags = entry[-4]
-
- if hostlist and not \
- (hosttags_match_taglist(tags_of_host(hostname), tags) and \
- in_extraconf_hostlist(hostlist, hostname)):
- continue
-
- # All entries need to be 3-Tuples to be compatible with the wato rule.
- # The third entry is a comment not used in the check anyway, so we just
- # fill it with None here.
- params["reclassify_patterns"].append((level, pattern, None))
-
return params
@@ -286,7 +250,7 @@ def inventory_logwatch(info):
# In case of a precompiled check, params contains the precompiled
-# logwatch_patterns for the logfile we deal with. If using check_mk
+# logwatch patterns for the logfile we deal with. If using check_mk
# without precompiled checks, the params must be None an will be
# ignored.
def check_logwatch(item, params, info):
diff --git a/cmk_base/check_api.py b/cmk_base/check_api.py
index 1083d5c..7b86370 100644
--- a/cmk_base/check_api.py
+++ b/cmk_base/check_api.py
@@ -214,13 +214,18 @@ no_discovery_possible = _check_api_utils.no_discovery_possible
service_extra_conf = _config.service_extra_conf
host_extra_conf = _config.host_extra_conf
in_binary_hostlist = _config.in_binary_hostlist
-in_extraconf_hostlist = _config.in_extraconf_hostlist
-hosttags_match_taglist = _config.hosttags_match_taglist
host_extra_conf_merged = _config.host_extra_conf_merged
+
+# TODO: Only used by logwatch check. Can we clean this up?
get_rule_options = _config.get_rule_options
all_matching_hosts = _config.all_matching_hosts
+# These functions were used in some specific checks until 1.6. Don't add it to
+# the future check API. It's kept here for compatibility reasons for now.
+in_extraconf_hostlist = _config.in_extraconf_hostlist
+hosttags_match_taglist = _config.hosttags_match_taglist
tags_of_host = _config.tags_of_host
+
nagios_illegal_chars = _config.nagios_illegal_chars
is_ipv6_primary = _config.is_ipv6_primary
is_cmc = _config.is_cmc
diff --git a/cmk_base/config.py b/cmk_base/config.py
index 155b419..ec99a5c 100644
--- a/cmk_base/config.py
+++ b/cmk_base/config.py
@@ -416,6 +416,7 @@ def _verify_no_deprecated_check_rulesets():
("services", "inventory_services"),
("domino_tasks", "inv_domino_tasks"),
("ps", "inventory_processes"),
+ ("logwatch", "logwatch_patterns"),
]
for check_plugin_name, varname in deprecated_rulesets:
check_context = get_check_context(check_plugin_name)