Module: check_mk
Branch: master
Commit: 615e5a19e0d2764af0c1acf7dd19ce56e4e13236
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=615e5a19e0d276…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue May 22 11:01:11 2012 +0200
New aggregation function count_ok
---
ChangeLog | 4 ++++
web/htdocs/bi.py | 13 +++++++++++++
2 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 5c9fe22..e293270 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,10 @@
* New display type 'boxes-omit-root' for BI views
* Hostgroup view BI Boxes omits the root level
+ BI:
+ * New aggregation function count_ok, that counts the number
+ of nodes in state OK.
+
1.2.0b4:
Core:
* New configuration variable snmp_timing, allowing to
diff --git a/web/htdocs/bi.py b/web/htdocs/bi.py
index 943d3be..6d19aa2 100644
--- a/web/htdocs/bi.py
+++ b/web/htdocs/bi.py
@@ -868,6 +868,19 @@ def aggr_best(nodes, n = 1, worst_state = CRIT):
config.aggregation_functions["worst"] = aggr_worst
config.aggregation_functions["best"] = aggr_best
+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 ])
+ if num_ok >= int(needed_for_ok):
+ return { "state" : 0, "output" : "" }
+ elif num_ok >= int(needed_for_warn):
+ return { "state" : 1, "output" : "" }
+ else:
+ return { "state" : 2, "output" : "%r / %d" %
(states, num_ok) }
+
+config.aggregation_functions["count_ok"] = aggr_countok
+
+
import re
def aggr_running_on(nodes, regex):