Module: check_mk
Branch: master
Commit: cba3ad40dba5d99316c2569efba33bc88eea96e5
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=cba3ad40dba5d9…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Apr 20 18:30:31 2011 +0200
BI: new aggregation function "running_on"
---
web/htdocs/bi.py | 24 ++++++++++++++++++++++++
1 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/web/htdocs/bi.py b/web/htdocs/bi.py
index c26725d..1f615e8 100644
--- a/web/htdocs/bi.py
+++ b/web/htdocs/bi.py
@@ -717,6 +717,30 @@ def aggr_best(nodes, n = 1, worst_state = CRIT):
config.aggregation_functions["worst"] = aggr_worst
config.aggregation_functions["best"] = aggr_best
+import re
+
+def aggr_running_on(nodes, regex):
+ first_check = nodes[0]
+
+ # extract hostname we run on
+ mo = re.match(regex, first_check[3])
+
+ # if not found, then do normal aggregation with 'worst'
+ if not mo or len(mo.groups()) == 0:
+ state, text = aggregation_functions['worst'](nodes[1:])
+ return state, text + ", running nowhere"
+
+ running_on = mo.groups()[0]
+ for host_node in nodes[1:]:
+ if host_node[2] == running_on:
+ return host_node[0], (host_node[3] + ", running on %s" %
running_on)
+
+ # host we run on not found. Strange...
+ return 3, "running on unknown host '%s'" % running_on
+
+config.aggregation_functions['running_on'] = aggr_running_on
+
+
# ____
# | _ \ __ _ __ _ ___ ___
# | |_) / _` |/ _` |/ _ \/ __|