Module: check_mk
Branch: master
Commit: 52d6cd043b2309176566fedaa723f972e505c65c
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=52d6cd043b2309…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Mar 27 10:59:36 2019 +0100
logwatch.ec: Start cleaning up precompile rule match logic
The host matching has been untied from the later item matching. This
makes it possible to replace the individual rule matching implementation
by generic functions in the next step.
Change-Id: I8804f0b6d2d41700d80bdb6ca5cf0bc286c48f36
---
checks/logwatch | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/checks/logwatch b/checks/logwatch
index 7c4adbd..5790ff7 100644
--- a/checks/logwatch
+++ b/checks/logwatch
@@ -1169,23 +1169,23 @@ def logwatch_ec_precompile(hostname, item, params):
# Directly compute set of all matching hosts here, this
# will avoid recomputation later
hosts = all_matching_hosts(tags, hostlist, with_foreign_hosts=False)
- ruleset.append((settings, hosts, servlist))
+ if hostname not in hosts:
+ continue
+
+ ruleset.append((settings, servlist))
- # Filter out any logwatch_rules which do apply to to this host
- # 1st filter: Do not use rules where the hostname does not match
- # 2nd filter: Do not use rules with configured items where no item matches the
- # "restrict_logfiles" condition (if applicable)
+ # Do not use rules with configured items where no item matches the
+ # "restrict_logfiles" condition (if applicable)
logwatch_settings = []
for rule in ruleset:
- settings, hosts, rule_items = rule
- if hostname in hosts:
- if params.get("restrict_logfiles"):
- for rule_item in rule_items:
- if rule_item == "" or
logwatch_ec_forwarding_enabled(params, rule_item):
- logwatch_settings.append((settings, rule_items))
- break
- else:
- logwatch_settings.append((settings, rule_items))
+ settings, rule_items = rule
+ if params.get("restrict_logfiles"):
+ for rule_item in rule_items:
+ if rule_item == "" or logwatch_ec_forwarding_enabled(params,
rule_item):
+ logwatch_settings.append((settings, rule_items))
+ break
+ else:
+ logwatch_settings.append((settings, rule_items))
params.update({"logwatch_settings": logwatch_settings})