Module: check_mk
Branch: master
Commit: 64a023090f0c190616c0e675f329f862aa35b508
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=64a023090f0c19…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Jul 28 12:06:12 2017 +0200
5047 FIX EC views: Fixed "Events of host X" views of unrelated events
When clicking on the host name of an unrelated event (one that has no host in the
monitoring core)
the target page was not showing any event since Check_MK 1.4. The events are now correctly
filtered
by the original event host instead of the host name of the found core host.
Change-Id: Ib61ae1c3f955845aa0fdfde1ac8c272717605707
---
.werks/5047 | 12 ++++++++++++
web/htdocs/views.py | 17 +++++++++++++++++
2 files changed, 29 insertions(+)
diff --git a/.werks/5047 b/.werks/5047
new file mode 100644
index 0000000..5923403
--- /dev/null
+++ b/.werks/5047
@@ -0,0 +1,12 @@
+Title: EC views: Fixed "Events of host X" views of unrelated events
+Level: 1
+Component: ec
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1501236224
+Class: fix
+
+When clicking on the host name of an unrelated event (one that has no host in the
monitoring core)
+the target page was not showing any event since Check_MK 1.4. The events are now
correctly filtered
+by the original event host instead of the host name of the found core host.
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index 08da98a..ab7822f 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -1504,6 +1504,22 @@ def show_view(view, show_heading = False, show_buttons = True,
if html.has_var('servicegroup') and not
html.has_var("optservice_group"):
html.set_var("optservice_group",
html.var("servicegroup"))
+ # TODO: Another hack :( Just like the above one: When opening the view
"ec_events_of_host",
+ # which is of single context "host" using a host name of a unrelated event,
the list of
+ # events is always empty since the single context filter "host" is sending
a "host_name = ..."
+ # filter to livestatus which is not matching a "unrelated event". Instead
the filter event_host
+ # needs to be used.
+ # Another idea: We could change these views to non single context views, but then we
would not
+ # be able to show the buttons to other host related views, which is also bad. So
better stick
+ # with the current mode.
+ if view["datasource"] in [ "mkeventd_events",
"mkeventd_history" ] and "host" in view["single_infos"]:
+ # Remove the original host name filter
+ use_filters = [ f for f in use_filters if f.name != "host" ]
+
+ # Set the value for the event host filter
+ if not html.has_var("event_host"):
+ html.set_var("event_host", html.var("host"))
+
# Now populate the HTML vars with context vars from the view definition. Hard
# coded default values are treated differently:
#
@@ -1514,6 +1530,7 @@ def show_view(view, show_heading = False, show_buttons = True,
# Check that all needed information for configured single contexts are available
visuals.verify_single_contexts('views', view,
datasource.get('link_filters', {}))
+
# Prepare Filter headers for Livestatus
# TODO: When this is used by the reporting then *all* filters are
# active. That way the inventory data will always be loaded. When