Module: check_mk
Branch: master
Commit: 8d1bb26249e89bb660f04edabacb882a192de481
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8d1bb26249e89b…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Jan 9 11:55:34 2017 +0100
4202 FIX Availability now avoids pending states for times before new hosts or services
were added
When computing the availability of a BI aggregation for a time range during
which new hosts or services were added to the monitoring the state of these
objects would be displayed as (PEND) before point of time they were added. But
this is not correct. These objects where not pending but simply not yet
existing and thus not contained in the aggregation tree at all at that time.
When computing a BI state it is a big difference if something is pending
or simply not existing. One pending node can make the total tree state also
(PEND). While this is correct in the current monitoring it breaks the
availability computation.
BI availability has now been fixed so that unmonitored hosts and services
are correctly being removed from the tree in the according time ranges and
the real state at that time is reconstructed. That way bogus (PEND) phases
of BI aggregations are being avoided.
Change-Id: I6772fdcb562b67738044bc22aa3cd2a09add6873
---
.werks/4202 | 23 +++++++++++++++++++++++
ChangeLog | 3 +++
web/htdocs/availability.py | 14 ++++++++++----
web/htdocs/bi.py | 14 +++++++++-----
4 files changed, 45 insertions(+), 9 deletions(-)
diff --git a/.werks/4202 b/.werks/4202
new file mode 100644
index 0000000..b9246e3
--- /dev/null
+++ b/.werks/4202
@@ -0,0 +1,23 @@
+Title: Availability now avoids pending states for times before new hosts or services were
added
+Level: 1
+Component: bi
+Compatible: compat
+Version: 1.4.0i4
+Date: 1483958830
+Class: fix
+
+When computing the availability of a BI aggregation for a time range during
+which new hosts or services were added to the monitoring the state of these
+objects would be displayed as (PEND) before point of time they were added. But
+this is not correct. These objects where not pending but simply not yet
+existing and thus not contained in the aggregation tree at all at that time.
+
+When computing a BI state it is a big difference if something is pending
+or simply not existing. One pending node can make the total tree state also
+(PEND). While this is correct in the current monitoring it breaks the
+availability computation.
+
+BI availability has now been fixed so that unmonitored hosts and services
+are correctly being removed from the tree in the according time ranges and
+the real state at that time is reconstructed. That way bogus (PEND) phases
+of BI aggregations are being avoided.
diff --git a/ChangeLog b/ChangeLog
index 24d2ca0..5edbf5d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -51,6 +51,9 @@
Notifications:
* 4197 FIX: Fix sending notification to global fallback email address
+ BI:
+ * 4202 FIX: Availability now avoids pending states for times before new hosts or
services were added...
+
Reporting & Availability:
* 3652 FIX: Unbreak PDF exports...
diff --git a/web/htdocs/availability.py b/web/htdocs/availability.py
index 3094d34..67f51bc 100644
--- a/web/htdocs/availability.py
+++ b/web/htdocs/availability.py
@@ -1681,13 +1681,16 @@ def compute_bi_tree_state(tree, status):
for site_host_service, state_output in status.items():
site_host = site_host_service[:2]
service = site_host_service[2]
+ state = state_output[0]
+ if state == -1:
+ state = None # Means: consider this object as missing
if service:
services_by_host.setdefault(site_host, []).append((
service, # service description
- state_output[0], # state
+ state,
1, # has_been_checked
state_output[1], # output
- state_output[0], # hard state (we use the soft state here)
+ state, # hard state (we use the soft state here)
1, # attempt
1, # max_attempts (not relevant)
state_output[2], # in_downtime
@@ -1699,9 +1702,12 @@ def compute_bi_tree_state(tree, status):
status_info = {}
for site_host, state_output in hosts.items():
+ state = state_output[0]
+ if state == -1:
+ state = None # Means: consider this object as missing
status_info[site_host] = [
- state_output[0],
- state_output[0], # host hard state
+ state,
+ state, # host hard state
state_output[1],
state_output[2], # in_downtime
False, # acknowledged
diff --git a/web/htdocs/bi.py b/web/htdocs/bi.py
index 74a987d..80fcaa0 100644
--- a/web/htdocs/bi.py
+++ b/web/htdocs/bi.py
@@ -2463,6 +2463,8 @@ def execute_rule_node(node, status_info, aggregation_options):
one_assumption = False
for n in node["nodes"]:
result = execute_node(n, status_info, aggregation_options) # state,
assumed_state, node [, subtrees]
+ if result[0]["state"] == None: # Omit this node (used in availability
for unmonitored things)
+ continue
subtrees.append(result)
# Assume items in downtime as CRIT when computing downtime state
@@ -2486,10 +2488,12 @@ def execute_rule_node(node, status_info, aggregation_options):
# no assumption, take real state into assumption array
assumed_states.append(node_states[-1])
- state = func(*([node_states] + funcargs))
-
- # Compute downtime state
- downtime_state = func(*([downtime_states] + funcargs))
+ if len(node_states) == 0:
+ state = { "state": None, "output" : _("Not yet
monitored") }
+ downtime_state = state
+ else:
+ state = func(*([node_states] + funcargs))
+ downtime_state = func(*([downtime_states] + funcargs))
if aggregation_options["downtime_aggr_warn"]:
state["in_downtime"] = downtime_state["state"] >= 1
@@ -3018,7 +3022,7 @@ def aggr_render_node(tree, title, show_host, mousecode=None,
img_class=None):
_("This element is currently not in its service period.")) + title
h = '<span class="content state state%d%s">%s</span>\n'
\
- % (effective_state["state"], addclass,
render_bi_state(effective_state["state"]))
+ % (effective_state["state"] if effective_state["state"] !=
None else -1, addclass, render_bi_state(effective_state["state"]))
if mousecode:
if img_class:
h += '<img src="images/tree_black_closed.png"
class="treeangle %s"%s>' % \