hostname also when cancelling events
Message-ID: <51fa6993.4G0e07dt7brUrh/r%mk(a)mathias-kettner.de>
User-Agent: Heirloom mailx 12.4 7/29/08
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Module: check_mk
Branch: master
Commit: b38d65cff909b0deea5daaae311fe83b885c35fa
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b38d65cff909b0…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Aug 1 15:57:08 2013 +0200
FIX: apply rewriting of application/hostname also when cancelling events
Conflicts:
mkeventd/bin/mkeventd
---
ChangeLog | 3 +++
mkeventd/bin/mkeventd | 30 +++++++++++++++++++++---------
2 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f9497af..58a1c7f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -295,6 +295,9 @@
* FIX: fix logwatch pattern analyzer message "The host xyz is not
managed by WATO." after direct access via snapin
+ Event Console:
+ * FIX: apply rewriting of application/hostname also when cancelling events
+
1.2.2p2:
Core:
* FIX: livecheck: fixed handling of one-line plugin outputs and missing \n
diff --git a/mkeventd/bin/mkeventd b/mkeventd/bin/mkeventd
index aedf770..6887e21 100755
--- a/mkeventd/bin/mkeventd
+++ b/mkeventd/bin/mkeventd
@@ -1487,7 +1487,7 @@ class EventServer:
return
if cancelling:
- g_event_status.cancel_events(event, groups, rule["id"])
+ g_event_status.cancel_events(event, groups, rule)
return
else:
@@ -2467,29 +2467,41 @@ class EventStatus():
# Cancel all events the belong to a certain rule id and are
# of the same "breed" as a new event.
- def cancel_events(self, new_event, match_groups, rule_id):
+ def cancel_events(self, new_event, match_groups, rule):
with lock_eventstatus:
to_delete = []
for nr, event in enumerate(self._events):
- if event["rule_id"] == rule_id:
- if self.cancelling_match(match_groups, new_event, event):
+ if event["rule_id"] == rule["id"]:
+ if self.cancelling_match(match_groups, new_event, event, rule):
log_event_history(event, "CANCELLED")
to_delete.append(nr)
for nr in to_delete[::-1]:
del self._events[nr]
- def cancelling_match(self, match_groups, new_event, event):
+ def cancelling_match(self, match_groups, new_event, event, rule):
debug = g_config["debug_rules"]
- if event["host"] != new_event["host"]:
+
+ # Note: before we compare host and application we need to
+ # apply the rewrite rules to the event. Because if in the previous
+ # the hostname was rewritten, it wouldn't match anymore here.
+ host = new_event["host"]
+ if "set_host" in rule:
+ host = replace_groups(rule["set_host"], host, match_groups)
+
+ if event["host"] != host:
if debug:
log("Do not cancel event %d: host is not the same (%s != %s)"
%
- (event["id"], event["host"],
new_event["host"]))
+ (event["id"], event["host"], host))
return False
- if event["application"] != new_event["application"]:
+ # The same for the application
+ application = new_event["application"]
+ if "set_application" in rule:
+ application = replace_groups(rule["set_application"], application,
match_groups)
+ if event["application"] != application:
if debug:
log("Do not cancel event %d: application is not the same (%s !=
%s)" %
- (event["id"], event["application"],
new_event["application"]))
+ (event["id"], event["application"],
application))
return False
if event["facility"] != new_event["facility"]: