Module: check_mk
Branch: master
Commit: df4da272c12144b62426924591869982aa773693
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=df4da272c12144…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Thu Apr 18 13:00:42 2019 +0200
6989 FIX Fix timestamp handling for events generated by rules expecting regular messages
Due to the event being rewritten at every new occurence in the case of expect rules,
the timestamp for the event's first occurence would always equal the one for the
last, making it useless. This has been fixed.
CMK-1843
Change-Id: Ie6bf99f19ae2bb31d1b4f6d99f62cdcc49601137
---
.werks/6989 | 13 +++++++++++++
cmk/ec/main.py | 7 ++++---
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/.werks/6989 b/.werks/6989
new file mode 100644
index 0000000..c2d3def
--- /dev/null
+++ b/.werks/6989
@@ -0,0 +1,13 @@
+Title: Fix timestamp handling for events generated by rules expecting regular messages
+Level: 1
+Component: ec
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1555511063
+
+Due to the event being rewritten at every new occurence in the case of expect rules,
+the timestamp for the event's first occurence would always equal the one for the
+last, making it useless. This has been fixed.
diff --git a/cmk/ec/main.py b/cmk/ec/main.py
index 71d7add..26f86d0 100644
--- a/cmk/ec/main.py
+++ b/cmk/ec/main.py
@@ -1286,7 +1286,7 @@ class EventServer(ECServerThread):
merge_event["text"] = text
# Better rewrite (again). Rule might have changed. Also we have changed
# the text and the user might have his own text added via set_text.
- self.rewrite_event(rule, merge_event, {})
+ self.rewrite_event(rule, merge_event, {}, set_first=False)
self._history.add(merge_event, "COUNTFAILED")
else:
# Create artifical event from scratch. Make sure that all important
@@ -1685,7 +1685,7 @@ class EventServer(ECServerThread):
return result
# Rewrite texts and compute other fields in the event
- def rewrite_event(self, rule, event, groups):
+ def rewrite_event(self, rule, event, groups, set_first=True):
if rule["state"] == -1:
prio = event["priority"]
if prio >= 5:
@@ -1708,7 +1708,8 @@ class EventServer(ECServerThread):
if ("sl" not in event) or (rule["sl"]["precedence"]
== "rule"):
event["sl"] = rule["sl"]["value"]
- event["first"] = event["time"]
+ if set_first:
+ event["first"] = event["time"]
event["last"] = event["time"]
if "set_comment" in rule:
event["comment"] = replace_groups(rule["set_comment"],
event["text"], groups)