Module: check_mk
Branch: master
Commit: 4b41eaf0ab29570faf722be19258c9f4557c4118
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4b41eaf0ab2957…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Aug 31 11:00:48 2017 +0200
Tests: Wait up to 10 seconds for EC/core config reload now
Change-Id: Id0833ba72a0d2a61f66cee5b637e4179e5906aa3
---
tests/testlib/__init__.py | 40 ++++++++++++++++++++++++++++------------
1 file changed, 28 insertions(+), 12 deletions(-)
diff --git a/tests/testlib/__init__.py b/tests/testlib/__init__.py
index 47eda37..e49ded7 100644
--- a/tests/testlib/__init__.py
+++ b/tests/testlib/__init__.py
@@ -1136,6 +1136,8 @@ class CMKWebSession(WebSession):
if allow_foreign_changes != None:
request["allow_foreign_changes"] = "1" if allow_foreign_changes else "0"
+ old_t = self.site.live.query_value("GET status\nColumns: program_start\n")
+
time_started = time.time()
result = self._api_request("webapi.py?action=activate_changes", {
"request": json.dumps(request),
@@ -1149,15 +1151,21 @@ class CMKWebSession(WebSession):
"Failed to activate %s: %r" % (site_id, status)
assert status["_time_ended"] > time_started
- # HACK: Activating changes can involve an asynchronous(!) monitoring
+ # Activating changes can involve an asynchronous(!) monitoring
# core restart/reload, so e.g. querying a Livestatus table immediately
- # might not reflect the changes yet. The right way to handle this would
- # be polling the "program_start" column of the "status" table until the
- # reload is complete. But this will only work if there is an actual
- # restart/reload involved, which we don't know here, only our caller.
- # Ugly workaround: Wait a moment and hope for the best, wasting a few
- # seconds is better than a false positive during testing... >:-P
- time.sleep(2)
+ # might not reflect the changes yet. Ask the core for a successful reload.
+ def config_reloaded():
+ new_t = self.site.live.query_value("GET status\nColumns: program_start\n")
+ print "New config load time: %s" % new_t
+ return new_t > old_t
+
+ reload_time, timeout = time.time(), 10
+ while not config_reloaded():
+ if time.time() > reload_time + timeout:
+ raise Exception("Config did not update within %d seconds" % timeout)
+ time.sleep(0.2)
+
+ assert config_reloaded()
def get_regular_graph(self, hostname, service_description, graph_index, expect_error=False):
@@ -1246,11 +1254,19 @@ class CMKEventConsole(CMKWebSession):
assert old_t > time.time() - 86400
super(CMKEventConsole, self).activate_changes(allow_foreign_changes=True)
- time.sleep(1)
- new_t = web.site.live.query_value("GET eventconsolestatus\nColumns: status_config_load_time\n")
- print "New config load time: %s" % new_t
- assert new_t > old_t
+ def config_reloaded():
+ new_t = web.site.live.query_value("GET eventconsolestatus\nColumns: status_config_load_time\n")
+ print "New config load time: %s" % new_t
+ return new_t > old_t
+
+ reload_time, timeout = time.time(), 10
+ while not config_reloaded():
+ if time.time() > reload_time + timeout:
+ raise Exception("Config did not update within %d seconds" % timeout)
+ time.sleep(0.2)
+
+ assert config_reloaded()
Module: check_mk
Branch: master
Commit: 00396545f0eb7a95d178266f91e33ee2bf5908bb
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=00396545f0eb7a…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Aug 30 16:05:04 2017 +0200
5057 FIX Fixed cancelling events by "syslog application" when using similar rules
When using two or more rules that both have a "match syslog application" condition and a
"syslog application to cancel event" condition while all other conditions are equal, it
could happen that the first rule always caught messages that should not be caught by that
rule. These messages were not handled by the second rule as expected.
Change-Id: Icdb5a02711ad43e411f89820c8bc3dc4d91087fd
---
.werks/5057 | 13 +++++++++++++
bin/mkeventd | 23 +++++++++++++----------
2 files changed, 26 insertions(+), 10 deletions(-)
diff --git a/.werks/5057 b/.werks/5057
new file mode 100644
index 0000000..bd1c867
--- /dev/null
+++ b/.werks/5057
@@ -0,0 +1,13 @@
+Title: Fixed cancelling events by "syslog application" when using similar rules
+Level: 1
+Component: ec
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1504101697
+Class: fix
+
+When using two or more rules that both have a "match syslog application" condition and a
+"syslog application to cancel event" condition while all other conditions are equal, it
+could happen that the first rule always caught messages that should not be caught by that
+rule. These messages were not handled by the second rule as expected.
diff --git a/bin/mkeventd b/bin/mkeventd
index 2467f42..61e0f5e 100755
--- a/bin/mkeventd
+++ b/bin/mkeventd
@@ -2459,11 +2459,21 @@ class EventServer(object):
self.logger.info(" did not match because of wrong source IP address '%s' (need '%s')" % (event["ipaddress"], rule.get("match_ipaddress")))
return False
+ cancel_by_application = False
+ if "cancel_application" in rule:
+ cancel_by_application = match(rule.get("cancel_application"),
+ event["application"],
+ complete=False) != False
+
if match(rule.get("match_application"), event["application"], complete=False) == False \
- and "cancel_application" not in rule:
+ and not cancel_by_application:
if debug:
- self.logger.info(" did not match because of wrong application '%s' (need '%s')" %
- (event["application"], pattern(rule.get("match_application"))))
+ need_msg = "need %r" % pattern(rule.get("match_application"))
+ if "cancel_application" in rule:
+ need_msg += " or %r for cancelling" % pattern(rule.get("cancel_application"))
+
+ self.logger.info(" did not match because of wrong application '%s' (%s)" %
+ (event["application"], need_msg))
return False
if "match_facility" in rule and event["facility"] != rule["match_facility"]:
@@ -2483,13 +2493,6 @@ class EventServer(object):
else:
cp = True
- if "cancel_application" in rule:
- cancel_by_application = match(rule.get("cancel_application"),
- event["application"],
- complete=False) != False
- else:
- cancel_by_application = True
-
match_groups = match(rule.get("match_ok", ""), event["text"], complete = False)
if match_groups != False and cp and cancel_by_application:
if debug:
Module: check_mk
Branch: master
Commit: 2ef6fca9920b445eeed884f0f2623842831c5b75
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2ef6fca9920b44…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Wed Aug 30 11:47:43 2017 +0200
df: Put duplicated logic determining the mountpoint in parse function
Change-Id: I9f5e1ee0b40d60d8ebe86d707f96717d14979298
---
checks/df | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/checks/df b/checks/df
index 7503bde..0cbd510 100644
--- a/checks/df
+++ b/checks/df
@@ -117,10 +117,11 @@ def parse_df(info):
device = line[0]
if device not in btrfs_devices:
btrfs_devices.add(device)
- df_blocks.append(line[:6] + [ "btrfs " + line[0] ]) # replace mount point with device
+ df_blocks.append(line[:6] + [ "btrfs " + device ]) # replace mount point with device
else:
- df_blocks.append(line)
+ mountpoint = " ".join(line[6:]).replace('\\', '/') # Windows \ is replaced with /
+ df_blocks.append(line[:6] + [ mountpoint ])
return df_blocks
def parse_inodes_subsection(inodes_subsection):
@@ -166,7 +167,7 @@ def inventory_df(parsed):
if line[2] == '-' or int(line[2]) == 0 or line[5] == '-':
continue # exclude filesystems without size
- mountpoint = " ".join(line[6:]).replace('\\', '/') # Windows \ is replaced with /
+ mountpoint = line[6]
if mountpoint in inventory_df_exclude_mountpoints:
continue # exclude this mount point (/tmp, /proc, whatever user wants)
@@ -183,7 +184,7 @@ def check_df(item, params, parsed):
# df outputs seven columns:
# DEVICE FS-TYPE SIZE(KB) USED(KB) AVAIL(KB) USED(%) MOUNTPOINT
# The mount point may contain spaces (seen on VMWare volumes and on ESX)
- mountpoint = " ".join(line[6:]).replace('\\', '/')
+ mountpoint = line[6]
if "patterns" in params or item == mountpoint:
# Beware: the 6th column of df ("used perc") may includes 5% which are reserved
# for the superuser, whereas the 4th colum ("used MB") does *not* include that.