Module: check_mk
Branch: master
Commit: 32ed15a3cc2237bde6fb7cbcc203890e76e8aa0a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=32ed15a3cc2237…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Sep 26 11:04:30 2014 +0200
#1406 Assume PEND in count_ok aggregations if all nodes are PEND
If you are using the BI aggregation function <tt>count_ok</tt> then nodes
with the state <tt>PEND</tt> (which essentially means unmonitored or not
present) are handled differently from now.
If <b>all</b> nodes are pending then the total state will also be pending.
If just some of the nodes are pending then they will not taken into account.
This is especially imported when doing availability computations on
BI aggregates.
---
.werks/1406 | 16 ++++++++++++++++
ChangeLog | 3 +++
web/htdocs/bi.py | 29 +++++++++++++++++++++++------
3 files changed, 42 insertions(+), 6 deletions(-)
diff --git a/.werks/1406 b/.werks/1406
new file mode 100644
index 0000000..b645eb0
--- /dev/null
+++ b/.werks/1406
@@ -0,0 +1,16 @@
+Title: Assume PEND in count_ok aggregations if all nodes are PEND
+Level: 2
+Component: bi
+Compatible: compat
+Version: 1.2.5i6
+Date: 1411721844
+Class: feature
+
+If you are using the BI aggregation function <tt>count_ok</tt> then nodes
+with the state <tt>PEND</tt> (which essentially means unmonitored or not
+present) are handled differently from now.
+
+If <b>all</b> nodes are pending then the total state will also be pending.
+If just some of the nodes are pending then they will not taken into account.
+This is especially imported when doing availability computations on
+BI aggregates.
diff --git a/ChangeLog b/ChangeLog
index e7fe90d..ebf9490 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -136,6 +136,9 @@
* 1156 FIX: Graphs in HTML mails are now sent again where they where missing...
* 1157 FIX: Fixed SMS plugin on at least debian (distrs which have no
sendsms/smssend)...
+ BI:
+ * 1406 Assume PEND in count_ok aggregations if all nodes are PEND...
+
Event Console:
* 1148 Allow execution of actions when cancelling events...
* 1395 Event Console can now create notifications via Check_MK RBN...
diff --git a/web/htdocs/bi.py b/web/htdocs/bi.py
index a133aaf..9fcbac7 100644
--- a/web/htdocs/bi.py
+++ b/web/htdocs/bi.py
@@ -1301,16 +1301,33 @@ def aggr_countok_convert(num, count):
def aggr_countok(nodes, needed_for_ok=2, needed_for_warn=1):
states = [ i[0]["state"] for i in nodes ]
- num_ok = len([s for s in states if s == 0 ])
+ num_ok = len([s for s in states if s == 0 ])
+ num_nonok = len([s for s in states if s > 0 ])
+ num_pending = len(states) - num_ok - num_nonok
+ num_nodes = num_ok + num_nonok
+
+ # We need to handle the special case "PENDING" separately.
+ # Example: count is set to 50%. You have 10 nodes, all of
+ # which are PENDING, then the outcome must be PENDING, not
+ # CRIT.
+ if num_nodes == 0: # All are pending
+ return { "state": -1, "output": "" }
# counts can be specified as integer (e.g. '2') or
# as percentages (e.g. '70%').
- if num_ok >= aggr_countok_convert(needed_for_ok, len(states)):
- return { "state" : 0, "output" : "" }
- elif num_ok >= aggr_countok_convert(needed_for_warn, len(states)):
- return { "state" : 1, "output" : "" }
+ ok_count = aggr_countok_convert(needed_for_ok, num_nodes)
+ warn_count = aggr_countok_convert(needed_for_warn, num_nodes)
+
+ # Enough nodes are OK -> state is OK
+ if num_ok >= ok_count:
+ return { "state": 0, "output": "" }
+
+ # Enough nodes OK in order to trigger warn level -> WARN
+ elif num_ok >= warn_count:
+ return { "state": 1, "output": "" }
+
else:
- return { "state" : 2, "output" : "" }
+ return { "state": 2, "output": "" }
config.aggregation_functions["count_ok"] = aggr_countok