Module: check_mk
Branch: master
Commit: d2a5d38d373b04cf316065bda90c53f40dbd1132
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d2a5d38d373b04…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Jul 20 15:42:20 2017 +0200
5003 FIX Fixed missing filtering by effective contact groups of events
Since 1.4 the Event console has the concept of "effective contact groups" for
an event. The contact groups of an event can either be set by a matched host
or by the matching rule. Or by both. For the later case there is an option
to configure the precedence in the rule.
The GUI was not correctly reflecting this feature because there was no painter
and no filter for the effective contact groups.
Change-Id: I81b0285f3f9b0dff8326ad58eabaf4c570e97a50
---
.werks/5003 | 17 +++++++++++++++
web/plugins/views/mkeventd.py | 28 ++++++++++++++++++++----
web/plugins/visuals/mkeventd.py | 47 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 88 insertions(+), 4 deletions(-)
diff --git a/.werks/5003 b/.werks/5003
new file mode 100644
index 0000000..c9b64a7
--- /dev/null
+++ b/.werks/5003
@@ -0,0 +1,17 @@
+Title: Fixed missing filtering by effective contact groups of events
+Level: 1
+Component: ec
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i1
+Date: 1500557807
+
+Since 1.4 the Event console has the concept of "effective contact groups" for
+an event. The contact groups of an event can either be set by a matched host
+or by the matching rule. Or by both. For the later case there is an option
+to configure the precedence in the rule.
+
+The GUI was not correctly reflecting this feature because there was no painter
+and no filter for the effective contact groups.
diff --git a/web/plugins/views/mkeventd.py b/web/plugins/views/mkeventd.py
index 99c5420..e16e0a5 100644
--- a/web/plugins/views/mkeventd.py
+++ b/web/plugins/views/mkeventd.py
@@ -441,11 +441,31 @@ if mkeventd_enabled:
multisite_painters["event_contact_groups"] = {
"title" : _("Contact groups defined in rule"),
- "short" : _("Rule Contact Groups"),
+ "short" : _("Rule contact groups"),
"columns" : [ "event_contact_groups" ],
"paint" : paint_event_contact_groups,
}
+ def paint_event_effective_contact_groups(row):
+ if row["event_contact_groups_precedence"] == "host":
+ cgs = row["host_contact_groups"]
+ else:
+ cgs = row["event_contact_groups"]
+
+ if cgs == None:
+ return "", ""
+ elif cgs:
+ return "", ", ".join(sorted(cgs))
+ else:
+ return "", "<i>" + _("none") +
"</i>"
+
+ multisite_painters["event_effective_contact_groups"] = {
+ "title" : _("Contact groups effective (Host or rule contact
groups)"),
+ "short" : _("Contact groups"),
+ "columns" : [ "event_contact_groups",
"event_contact_groups_precedence", "host_contact_groups" ],
+ "paint" : paint_event_effective_contact_groups,
+ }
+
# Event History
multisite_painters["history_line"] = {
@@ -942,7 +962,7 @@ if mkeventd_enabled:
('event_count', None, None),
('event_sl', None, None),
('event_contact', None, None),
- ('event_contact_groups', None, None),
+ ('event_effective_contact_groups', None, None),
('event_application', None, None),
('event_pid', None, None),
('event_priority', None, None),
@@ -1044,7 +1064,7 @@ if mkeventd_enabled:
('event_count', None, None),
('event_sl', None, None),
('event_contact', None, None),
- ('event_contact_groups', None, None),
+ ('event_effective_contact_groups', None, None),
('event_application', None, None),
('event_pid', None, None),
('event_priority', None, None),
@@ -1176,7 +1196,7 @@ if mkeventd_enabled:
('event_count', None, None),
('event_sl', None, None),
('event_contact', None, None),
- ('event_contact_groups', None, None),
+ ('event_effective_contact_groups', None, None),
('event_application', None, None),
('event_pid', None, None),
('event_priority', None, None),
diff --git a/web/plugins/visuals/mkeventd.py b/web/plugins/visuals/mkeventd.py
index b28acac..2d35e1d 100644
--- a/web/plugins/visuals/mkeventd.py
+++ b/web/plugins/visuals/mkeventd.py
@@ -196,3 +196,50 @@ if mkeventd_enabled:
declare_filter(210, EventFilterDropdown("facility", _("Syslog
Facility"), mkeventd.syslog_facilities))
declare_filter(211, EventFilterDropdown("sl", _("Service Level at
least"), mkeventd.service_levels, operator='>='))
declare_filter(211, EventFilterDropdown("sl_max", _("Service Level at
most"), mkeventd.service_levels, operator='<=', column="sl"))
+
+
+ class EventFilterEffectiveContactGroupCombo(FilterGroupCombo):
+ def __init__(self, enforce=False):
+ # TODO: Cleanup hierarchy here. The FilterGroupCombo constructor needs to be
refactored
+ FilterGroupCombo.__init__(self,
+ what="event_effective_contact",
+ title=_("Contact group (effective)"),
+ enforce=enforce,
+ )
+ self.what = "contact"
+ self.info = "event"
+ self.link_columns = [ "event_contact_groups",
"event_contact_groups_precedence", "host_contact_groups" ]
+
+
+ def filter(self, infoname):
+ if not html.has_var(self.htmlvars[0]):
+ return "" # Skip if filter is not being set at all
+
+ current_value = self.current_value()
+ if not current_value:
+ if not self.enforce:
+ return ""
+ current_value = sites.live().query_value("GET contactgroups\nCache:
reload\nColumns: name\nLimit: 1\n", None)
+
+ if current_value == None:
+ return "" # no {what}group exists!
+
+ if not self.enforce and html.var(self.htmlvars[1]):
+ negate = "!"
+ else:
+ negate = ""
+
+ return "Filter: event_contact_groups_precedence = host\n" \
+ "Filter: host_contact_groups %s>= %s\n" \
+ "And: 2\n" \
+ "Filter: event_contact_groups_precedence = rule\n" \
+ "Filter: event_contact_groups %s>= %s\n" \
+ "And: 2\n" \
+ "Or: 2\n" % (negate, lqencode(current_value),
+ negate, lqencode(current_value))
+
+
+ def variable_settings(self, row):
+ return []
+
+ declare_filter(212, EventFilterEffectiveContactGroupCombo())