Module: check_mk
Branch: master
Commit: de600209f034974ee9a33b17997770302d1b42aa
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=de600209f03497…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Dec 4 09:42:43 2017 +0100
5564 FIX Fixed site filter when using "analyse notification"
When analyzing notifications forwarded from remote sites, the site filter did not work as
intended. The site filter was always using the local (central) site ID as value for
OMD_SITE
instead of the origin site.
Change-Id: I6ec79ef298cce27c1dea48e6a5ff6299f62c8701
---
.werks/5564 | 12 ++++++++++++
cmk_base/events.py | 17 +++++++++++++----
2 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/.werks/5564 b/.werks/5564
new file mode 100644
index 0000000..c4d6e31
--- /dev/null
+++ b/.werks/5564
@@ -0,0 +1,12 @@
+Title: Fixed site filter when using "analyse notification"
+Level: 1
+Component: notifications
+Compatible: compat
+Edition: cee
+Version: 1.5.0i2
+Date: 1512376886
+Class: fix
+
+When analyzing notifications forwarded from remote sites, the site filter did not work
as
+intended. The site filter was always using the local (central) site ID as value for
OMD_SITE
+instead of the origin site.
diff --git a/cmk_base/events.py b/cmk_base/events.py
index 1f20f1e..7766eae 100644
--- a/cmk_base/events.py
+++ b/cmk_base/events.py
@@ -265,15 +265,24 @@ def add_rulebased_macros(raw_context):
raw_context["CONTACTNAME"] = "check-mk-notify"
-# Add a few further helper variables that are useful in notification and alert plugins
def complete_raw_context(raw_context, with_dump, event_log):
+ """Extend the raw notification context
+
+ This ensures that all raw contexts processed in the notification code has specific
variables
+ set. Add a few further helper variables that are useful in notification and alert
plugins.
+
+ Please not that this is not only executed on the source system. When notifications
are
+ forwarded to another site and the analysis is executed on that site, this function
will be
+ executed on the central site. So be sure not to overwrite site specific things.
+ """
raw_keys = list(raw_context.keys())
try:
raw_context["WHAT"] = raw_context.get("SERVICEDESC") and
"SERVICE" or "HOST"
- raw_context["MONITORING_HOST"] = socket.gethostname()
- raw_context["OMD_ROOT"] = cmk.paths.omd_root
- raw_context["OMD_SITE"] = cmk.omd_site()
+
+ raw_context.setdefault("MONITORING_HOST", socket.gethostname())
+ raw_context.setdefault("OMD_ROOT", cmk.paths.omd_root)
+ raw_context.setdefault("OMD_SITE", cmk.omd_site())
# The Check_MK Micro Core sends the MICROTIME and no other time stamps. We add
# a few Nagios-like variants in order to be compatible