trailing spaces from localizable strings
Message-ID: <591ea63e.vR0eXfeUP37IZTSV%lm(a)mathias-kettner.de>
User-Agent: Heirloom mailx 12.5 6/20/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Module: check_mk
Branch: master
Commit: f3203103105f15239b8edd7a08e5e29e89e90ea7
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f3203103105f15…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri May 19 09:49:36 2017 +0200
Ruleset conditions: small code cleanup and removed leading/trailing spaces from localizable strings
Change-Id: I41633f22eaa2da8ac7833458ed7cb5071de0ab7f
---
web/htdocs/wato.py | 103 +++++++++++++++++++++++++++++------------------------
1 file changed, 56 insertions(+), 47 deletions(-)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 73c5ff1..59a014d 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -13216,63 +13216,72 @@ class ModeEditRuleset(WatoMode):
def _host_conditions(self, rule):
if rule.host_list == ALL_HOSTS:
return
+ # Other cases should not occur, e.g. list of explicit hosts
+ # plus ALL_HOSTS.
+ condition = self._render_host_condition_text(rule)
+ if condition:
+ html.li(condition, class_="condition")
- condition = None
+
+ def _render_host_condition_text(self, rule):
if rule.host_list == []:
- condition = _("This rule does <b>never</b> apply due to an empty list of explicit hosts!")
+ return _("This rule does <b>never</b> apply due to an empty list of explicit hosts!")
+
+ condition, text_list = [], []
+
+ if rule.host_list[0][0] == ENTRY_NEGATE_CHAR:
+ host_list = rule.host_list[:-1]
+ is_negate = True
else:
- text_list = []
+ is_negate = False
+ host_list = rule.host_list
- if rule.host_list[0][0] == ENTRY_NEGATE_CHAR:
- host_list = rule.host_list[:-1]
- is_negate = True
- else:
- is_negate = False
- host_list = rule.host_list
+ regex_count = len([x for x in host_list if "~" in x])
- regex_count = len([x for x in host_list if "~" in x])
+ condition.append(_("Host name"))
- condition = _("Host name ")
+ if regex_count == len(host_list) or regex_count == 0:
# Entries are either complete regex or no regex at all
- if regex_count == len(host_list) or regex_count == 0:
- is_regex = regex_count > 0
- if is_regex:
- condition += is_negate and _("is not one of regex ") or _("matches one of regex ")
- else:
- condition += is_negate and _("is not one of ") or _("is ")
-
- for host_spec in host_list:
- if not is_regex:
- host = Host.host(host_spec)
- if host:
- host_spec = '<a href="%s">%s</a>' % (html.attrencode(host.edit_url()), host_spec)
- text_list.append(html.render_b(host_spec.strip("!").strip("~")))
- # Mixed entries
+ is_regex = regex_count > 0
+ if is_regex:
+ condition.append(_("is not one of regex")
+ if is_negate else _("matches one of regex"))
else:
- for host_spec in host_list:
- is_regex = "~" in host_spec
- host_spec = host_spec.strip("!").strip("~")
- if not is_regex:
- host = Host.host(host_spec)
- if host:
- host_spec = '<a href="%s">%s</a>' % (html.attrencode(host.edit_url()), host_spec)
-
- if is_negate:
- expression = "%s" % (is_regex and _("does not match regex ") or _("is not "))
- else:
- expression = "%s" % (is_regex and _("matches regex ") or _("is "))
- text_list.append("%s%s" % (expression, html.render_b(host_spec)))
+ condition.append(_("is not one of")
+ if is_negate else _("is"))
- if len(text_list) == 1:
- condition += text_list[0]
- else:
- condition += ", ".join([ "%s" % s for s in text_list[:-1] ])
- condition += _(" or ") + text_list[-1]
+ for host_spec in host_list:
+ if not is_regex:
+ host = Host.host(host_spec)
+ if host:
+ host_spec = html.render_a(host_spec, host.edit_url())
+
+ text_list.append(html.render_b(host_spec.strip("!").strip("~")))
+
+ else:
+ # Mixed entries
+ for host_spec in host_list:
+ is_regex = "~" in host_spec
+ host_spec = host_spec.strip("!").strip("~")
+ if not is_regex:
+ host = Host.host(host_spec)
+ if host:
+ host_spec = html.render_a(host_spec, host.edit_url())
+
+ if is_negate:
+ expression = "%s" % (is_regex and _("does not match regex") or _("is not"))
+ else:
+ expression = "%s" % (is_regex and _("matches regex") or _("is "))
+ text_list.append("%s %s" % (expression, html.render_b(host_spec)))
+
+ if len(text_list) == 1:
+ condition.append(text_list[0])
+ else:
+ condition.append(", ".join([ "%s" % s for s in text_list[:-1] ]))
+ condition.append(_(" or ") + text_list[-1])
+
+ return HTML(" ").join(condition)
- # Other cases should not occur, e.g. list of explicit hosts
- # plus ALL_HOSTS.
- if condition:
- html.li(condition, class_="condition")
def _service_conditions(self, rule):
Module: check_mk
Branch: master
Commit: 8df7d5830a03d60dad6ad64b4ca37b3b3d578fe0
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8df7d5830a03d6…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri May 19 09:35:51 2017 +0200
4728 FIX Check_MK service: Fixed handling of "State in case of empty agent output"
The Check_MK service was not respecting the state configured in the ruleset
"Status of Check_MK service" for the case where no data is provided by the
agent.
Change-Id: I09adfda60de7826e458f586e5ee3735f75b01723
---
.werks/4728 | 13 +++++++++++++
modules/check_mk_base.py | 11 ++++++++++-
2 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/.werks/4728 b/.werks/4728
new file mode 100644
index 0000000..aac3620
--- /dev/null
+++ b/.werks/4728
@@ -0,0 +1,13 @@
+Title: Check_MK service: Fixed handling of "State in case of empty agent output"
+Level: 1
+Component: core
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i1
+Date: 1495179272
+
+The Check_MK service was not respecting the state configured in the ruleset
+"Status of Check_MK service" for the case where no data is provided by the
+agent.
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index 00b5861..bba4dc5 100644
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -1218,13 +1218,20 @@ def do_check(hostname, ipaddress, only_check_types = None):
save_item_state(hostname)
if problems:
output = "%s, " % problems
- status = exit_spec.get("connection", 2)
+
+ if problems == "Empty output from agent":
+ status = exit_spec.get("empty_output", 2)
+ else:
+ status = exit_spec.get("connection", 2)
+
elif num_errors > 0 and num_success > 0:
output = "Missing agent sections: %s - " % ", ".join(error_sections)
status = exit_spec.get("missing_sections", 1)
+
elif num_errors > 0:
output = "Got no information from host, "
status = exit_spec.get("empty_output", 2)
+
elif expected_version and agent_version \
and not is_expected_agent_version(agent_version, expected_version):
# expected version can either be:
@@ -1243,9 +1250,11 @@ def do_check(hostname, ipaddress, only_check_types = None):
expected = expected_version
output = "unexpected agent version %s (should be %s), " % (agent_version, expected)
status = exit_spec.get("wrong_version", 1)
+
elif agent_min_version and agent_version < agent_min_version:
output = "old plugin version %s (should be at least %s), " % (agent_version, agent_min_version)
status = exit_spec.get("wrong_version", 1)
+
else:
output = ""
if not is_cluster(hostname) and agent_version != None:
Module: check_mk
Branch: master
Commit: 087cf3627482045379fb81af3e30c7161b99cb83
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=087cf362748204…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu May 18 14:25:18 2017 +0200
4725 FIX Significant improvement of Check_MK check helper memory usage
The memory usage of the Check_MK check helpers, especially the growth
that occures during runtime, has been reduced significantly.
One example which has been measured in a single site with 30 Check_MK
check helpers configured and a large configuration
(a lot of hosts, services, tags and rulesets):
Before this change it was executing 1000 service checks per second with
a total memory usage of about 15 GB.
After this change it is now performing 1100 service checks per second
with a total memory usage of 3.5(!) GB.
The exact memory reduction highly depends on the Check_MK configuration,
but should be measurable in all medium to large environments.
Change-Id: I42e2a6f9da071b0a5f302bb41d7ae1db973fccc3
---
.werks/4725 | 24 ++++++++++++++++++++++++
cmk_base/rulesets.py | 11 -----------
2 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/.werks/4725 b/.werks/4725
new file mode 100644
index 0000000..ca51887
--- /dev/null
+++ b/.werks/4725
@@ -0,0 +1,24 @@
+Title: Significant improvement of Check_MK check helper memory usage
+Level: 2
+Component: core
+Compatible: compat
+Edition: cee
+Version: 1.5.0i1
+Date: 1495108890
+Class: fix
+
+The memory usage of the Check_MK check helpers, especially the growth
+that occures during runtime, has been reduced significantly.
+
+One example which has been measured in a single site with 30 Check_MK
+check helpers configured and a large configuration
+(a lot of hosts, services, tags and rulesets):
+
+Before this change it was executing 1000 service checks per second with
+a total memory usage of about 15 GB.
+
+After this change it is now performing 1100 service checks per second
+with a total memory usage of 3.5(!) GB.
+
+The exact memory reduction highly depends on the Check_MK configuration,
+but should be measurable in all medium to large environments.
diff --git a/cmk_base/rulesets.py b/cmk_base/rulesets.py
index 10536c4..ee5b762 100644
--- a/cmk_base/rulesets.py
+++ b/cmk_base/rulesets.py
@@ -61,15 +61,6 @@ def get_rule_options(entry):
# for those negated with '!'. Those the host must *not* have!
# New in 1.1.13: a trailing + means a prefix match
def hosttags_match_taglist(hosttags, required_tags):
- cache = cmk_base.config_cache.get_dict("hosttags_match_taglist")
-
- cache_id = tuple(hosttags), tuple(required_tags)
-
- try:
- return cache[cache_id]
- except KeyError:
- pass
-
for tag in required_tags:
negate, tag = parse_negated(tag)
if tag and tag[-1] == '+':
@@ -84,10 +75,8 @@ def hosttags_match_taglist(hosttags, required_tags):
matches = tag in hosttags
if matches == negate:
- cache[cache_id] = False
return False
- cache[cache_id] = True
return True