Module: check_mk
Branch: master
Commit: 27eb29c9b02fac759e478948900fde0e315503b1
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=27eb29c9b02fac…
Author: Sebastian Herbord <sh(a)mathias-kettner.de>
Date: Tue Sep 22 13:22:55 2015 +0200
#2629 BI Aggregations now adopt downtime from hosts
Up till now, bi aggregations did not display host downtimes, only service downtimes.
Now a host downtime is propagated through all levels of the aggregation the same as
service
downtimes.
---
.werks/2629 | 11 +++++++++++
ChangeLog | 1 +
web/htdocs/bi.py | 33 ++++++++++++++++++++++++---------
web/plugins/views/bi.py | 8 +++++---
4 files changed, 41 insertions(+), 12 deletions(-)
diff --git a/.werks/2629 b/.werks/2629
new file mode 100644
index 0000000..fcd8c85
--- /dev/null
+++ b/.werks/2629
@@ -0,0 +1,11 @@
+Title: BI Aggregations now adopt downtime from hosts
+Level: 1
+Component: bi
+Compatible: compat
+Version: 1.2.7i3
+Date: 1442920839
+Class: feature
+
+Up till now, bi aggregations did not display host downtimes, only service downtimes.
+Now a host downtime is propagated through all levels of the aggregation the same as
service
+downtimes.
diff --git a/ChangeLog b/ChangeLog
index 56a644b..d897bde 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -286,6 +286,7 @@
BI:
* 2537 BI Editor: restructured, now show tree structure of aggregations, show unused
rules...
+ * 2629 BI Aggregations now adopt downtime from hosts...
* 2369 FIX: Fix exception in BI availability via table "Hostname
Aggregations"
* 2370 FIX: Fix computation of "in downtime" and "acknownledged"
of hosts in BI aggregations...
* 2485 FIX: Fix Icon "BI Aggregations containing this service", also avoid
BI compilation without need...
diff --git a/web/htdocs/bi.py b/web/htdocs/bi.py
index 060abb8..1f04c9f 100644
--- a/web/htdocs/bi.py
+++ b/web/htdocs/bi.py
@@ -492,12 +492,12 @@ def compile_rule_node(aggr_type, calllist, lvl):
config.FOREACH_SERVICE ]:
matches = find_matching_services(aggr_type, what, calllist[1:])
new_elements = []
- handled_args = set([]) # avoid duplicate rule incarnations
+ handled_args = set() # avoid duplicate rule incarnations
for match in matches:
args = [ substitute_matches(a, match) for a in arglist ]
- if tuple(args) not in handled_args:
+ if tuple(args) not in handled_args:
new_elements += compile_aggregation_rule(aggr_type, rule, args, lvl)
- handled_args.add(tuple(args))
+ handled_args.add(tuple(args))
return new_elements
else:
@@ -775,12 +775,12 @@ def compile_aggregation_rule(aggr_type, rule, args, lvl):
calllist.append(n)
matches = find_matching_services(aggr_type, node[0], calllist)
new_elements = []
- handled_args = set([]) # avoid duplicate rule incarnations
+ handled_args = set() # avoid duplicate rule incarnations
for match in matches:
sub_arginfo = dict([(str(n+1), x) for (n,x) in enumerate(match)])
- if tuple(args) + match not in handled_args:
+ if tuple(args) + match not in handled_args:
new_elements += compile_leaf_node(subst_vars(node[-2],
sub_arginfo), subst_vars(node[-1], sub_arginfo))
- handled_args.add(tuple(args) + match)
+ handled_args.add(tuple(args) + match)
host_name, service_description = node[-2:]
else:
@@ -1030,6 +1030,7 @@ def execute_leaf_node(node, status_info, use_hard_states):
"state" : MISSING,
"output" : _("Host %s not found") % host,
"in_downtime" : False,
+ "host_in_downtime" : False,
"acknowledged" : False,
"in_service_period" : True,
}, None, node)
@@ -1060,6 +1061,7 @@ def execute_leaf_node(node, status_info, use_hard_states):
"state" : st,
"output" : output,
"in_downtime" : downtime_depth > 0,
+ "host_in_downtime" : host_in_downtime != 0,
"acknowledged" : not not acknowledged,
"in_service_period" : in_service_period,
}
@@ -1068,6 +1070,7 @@ def execute_leaf_node(node, status_info, use_hard_states):
"state" : state_assumption,
"output" : _("Assumed to be %s") %
service_state_names[state_assumption],
"in_downtime" : downtime_depth > 0,
+ "host_in_downtime" : host_in_downtime != 0,
"acknowledged" : not not acknowledged,
"in_service_period" : in_service_period,
}
@@ -1080,6 +1083,7 @@ def execute_leaf_node(node, status_info, use_hard_states):
"state" : MISSING,
"output" : _("This host has no such
service"),
"in_downtime" : False,
+ "host_in_downtime" : host_in_downtime != 0,
"acknowledged" : False,
"in_service_period" : True,
}, None, node)
@@ -1093,7 +1097,8 @@ def execute_leaf_node(node, status_info, use_hard_states):
state = {
"state" : aggr_state,
"output" : host_output,
- "in_downtime" : host_in_downtime,
+ "in_downtime" : False,
+ "host_in_downtime" : host_in_downtime != 0,
"acknowledged" : host_acknowledged,
"in_service_period" : host_in_service_period,
}
@@ -1101,7 +1106,8 @@ def execute_leaf_node(node, status_info, use_hard_states):
assumed_state = {
"state" : state_assumption,
"output" : _("Assumed to be %s") %
host_state_names[state_assumption],
- "in_downtime" : host_in_downtime,
+ "in_downtime" : False,
+ "host_in_downtime" : host_in_downtime != 0,
"acknowledged" : host_acknowledged,
"in_service_period" : host_in_service_period,
}
@@ -1126,6 +1132,7 @@ def execute_rule_node(node, status_info, use_hard_states):
node_states = []
assumed_states = []
downtime_states = []
+ host_downtime_states = []
service_period_states = []
ack_states = [] # Needed for computing the acknowledgement of non-OK nodes
one_assumption = False
@@ -1135,6 +1142,7 @@ def execute_rule_node(node, status_info, use_hard_states):
# Assume items in downtime as CRIT when computing downtime state
downtime_states.append(({"state": result[0]["in_downtime"]
and 2 or 0, "output" : ""}, result[2]))
+ host_downtime_states.append(({"state":
result[0]["host_in_downtime"] and 2 or 0, "output" : ""},
result[2]))
# Assume non-OK nodes that are acked as OK
if result[0]["acknowledged"]:
@@ -1158,7 +1166,10 @@ def execute_rule_node(node, status_info, use_hard_states):
# Compute downtime state
downtime_state = func(*([downtime_states] + funcargs))
+ host_downtime_state = func(*([host_downtime_states] + funcargs))
+
state["in_downtime"] = downtime_state["state"] >= 2
+ state["host_in_downtime"] = host_downtime_state["state"] >= 2
# Compute acknowledgedment state
if state["state"] > 0: # Non-OK-State -> compute acknowledgedment
@@ -1174,6 +1185,7 @@ def execute_rule_node(node, status_info, use_hard_states):
if one_assumption:
assumed_state = func(*([assumed_states] + funcargs))
assumed_state["in_downtime"] = state["in_downtime"]
+ assumed_state["host_in_downtime"] =
state["host_in_downtime"]
assumed_state["acknowledged"] = state["acknowledged"]
assumed_state["in_service_period"] =
state["in_service_period"]
else:
@@ -1597,7 +1609,6 @@ def render_tree_foldable(row, boxes, omit_root, expansion_level,
only_problems,
return "aggrtree" + (boxes and "_box" or ""), htmlcode
def aggr_render_node(tree, title, mousecode, show_host):
-
# Check if we have an assumed state: comparing assumed state (tree[1]) with state
(tree[0])
if tree[1] and tree[0] != tree[1]:
addclass = " " + _("assumed")
@@ -1609,6 +1620,10 @@ def aggr_render_node(tree, title, mousecode, show_host):
if tree[0]["in_downtime"]:
title = ('<img class="icon bi"
src="images/icon_downtime.png" title="%s">' % \
_("This element is currently in a scheduled downtime.")) + title
+ elif tree[0]["host_in_downtime"]:
+ # only display host downtime if the service has no own downtime
+ title = ('<img class="icon bi"
src="images/icon_hostdowntime.png" title="%s">' % \
+ _("The host is currently in downtime.")) + title
if tree[0]["acknowledged"]:
title = ('<img class="icon bi"
src="images/icon_ack.png" title="%s">' % \
diff --git a/web/plugins/views/bi.py b/web/plugins/views/bi.py
index de2301c..573f415 100644
--- a/web/plugins/views/bi.py
+++ b/web/plugins/views/bi.py
@@ -86,11 +86,13 @@ def paint_bi_icons(row):
avail_url = single_url + "&mode=availability"
html.icon_button(avail_url, _("Analyse availability of this aggregation"),
"availability")
if row["aggr_effective_state"]["in_downtime"]:
- html.icon(_("This aggregation is currently in a scheduled downtime."),
"downtime")
+ html.icon(_("This aggregation is currently in a scheduled downtime."),
"downtime")
+ elif row["aggr_effective_state"]["host_in_downtime"]:
+ html.icon(_("This aggregation is currently in a scheduled downtime."),
"hostdowntime")
if row["aggr_effective_state"]["acknowledged"]:
- html.icon(_("The critical problems that make this aggregation non-OK have been
acknowledged."), "ack")
+ html.icon(_("The critical problems that make this aggregation non-OK have
been acknowledged."), "ack")
if not row["aggr_effective_state"]["in_service_period"]:
- html.icon(_("This aggregation is currently out of its service period."),
"outof_serviceperiod")
+ html.icon(_("This aggregation is currently out of its service
period."), "outof_serviceperiod")
code = html.drain()
html.unplug()
return "buttons", code