Module: check_mk
Branch: master
Commit: 059e9f56100c9b17b85bdbce93637591352b6f0e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=059e9f56100c9b…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Apr 21 16:31:25 2011 +0200
BI: make running_on work again
---
web/htdocs/bi.py | 22 +++++++++++++---------
web/plugins/views/bi.py | 6 +++++-
2 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/web/htdocs/bi.py b/web/htdocs/bi.py
index fae5fba..ceb010c 100644
--- a/web/htdocs/bi.py
+++ b/web/htdocs/bi.py
@@ -44,7 +44,7 @@ UNKNOWN = 3
UNAVAIL = 4
service_state_names = { OK:"OK", WARN:"WARN", CRIT:"CRIT",
UNKNOWN:"UNKNOWN", PENDING:"PENDING",
UNAVAIL:"UNAVAILABLE"}
-host_state_names = { OK:"UP", CRIT:"DOWN",
UNKNOWN:"UNREACHABLE" }
+host_state_names = { 0:"UP", 1:"DOWN", 2:"UNREACHABLE" }
# character that separates sites and hosts
@@ -669,7 +669,8 @@ def execute_leaf_node(node, status_info):
aggr_state = {0:OK, 1:CRIT, 2:UNKNOWN}[host_state]
state = {"state":aggr_state, "output" : host_output}
if state_assumption != None:
- assumed_state = {"state":assumed_state, "output" :
"Assumed to be %s" % host_state_names[state_assumption]}
+ assumed_state = {"state": state_assumption,
+ "output" : "Assumed to be %s" %
host_state_names[state_assumption]}
else:
assumed_state = None
return (state, assumed_state, node)
@@ -826,20 +827,23 @@ def aggr_running_on(nodes, regex):
first_check = nodes[0]
# extract hostname we run on
- mo = re.match(regex, first_check[3])
+ mo = re.match(regex, first_check[0]["output"])
# 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"
+ state = aggregation_functions['worst'](nodes[1:])
+ state["output"] += ", running nowhere"
+ return state
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)
+ for state, node in nodes[1:]:
+ for site, host in node["reqhosts"]:
+ if host == running_on:
+ state["output"] += ", running on %s" % running_on
+ return state
# host we run on not found. Strange...
- return 3, "running on unknown host '%s'" % running_on
+ return {"state": UNKNOWN, "output": "running on unknown host
'%s'" % running_on }
config.aggregation_functions['running_on'] = aggr_running_on
diff --git a/web/plugins/views/bi.py b/web/plugins/views/bi.py
index 35b0a63..819a75e 100644
--- a/web/plugins/views/bi.py
+++ b/web/plugins/views/bi.py
@@ -498,7 +498,11 @@ class BIStatusFilter(Filter):
allowed_states.append(s)
newrows = []
for row in rows:
- if row[self.column]["state"] in allowed_states:
+ if row[self.column] != None:
+ s = row[self.column]["state"]
+ else:
+ s = None
+ if s in allowed_states:
newrows.append(row)
return newrows