Module: check_mk
Branch: master
Commit: 999098659845ca6c83ff104fa5f1c5581b091b43
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=999098659845ca…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Thu Apr 6 15:28:35 2017 +0200
4469 BI aggregations: Views containing multiple aggregations now render faster
Change-Id: I25d0db2968e58eeeec6baf5c6874a2065f1d6e94
---
.werks/4469 | 10 ++++++++++
web/htdocs/bi.py | 29 +++++++++++++++++++++++------
2 files changed, 33 insertions(+), 6 deletions(-)
diff --git a/.werks/4469 b/.werks/4469
new file mode 100644
index 0000000..4c83ce4
--- /dev/null
+++ b/.werks/4469
@@ -0,0 +1,10 @@
+Title: BI aggregations: Views containing multiple aggregations now render faster
+Level: 1
+Component: bi
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1491485215
+Class: feature
+
+
diff --git a/web/htdocs/bi.py b/web/htdocs/bi.py
index bfd28a6..5253730 100644
--- a/web/htdocs/bi.py
+++ b/web/htdocs/bi.py
@@ -3123,19 +3123,36 @@ def table(columns, add_headers, only_sites, limit, filters):
online_sites = set(map(lambda x: x[0],
get_current_sitestats()["online_sites"]))
+
+ # Prefetch data for later usage - this saves lots of redundant livestatus queries
+ def is_tree_required(tree):
+ if only_aggr_name and only_aggr_name != tree.get("title"):
+ return False
+
+ aggr_sites = set(x[0] for x in tree.get("reqhosts"))
+ if not aggr_sites.intersection(online_sites):
+ return False
+ return True
+
+
+ required_hosts = set()
+ for group, trees in items:
+ for tree in trees:
+ if not is_tree_required(tree):
+ continue
+ required_hosts.update(tree.get("reqhosts"))
+ status_info = get_status_info(required_hosts)
+
+
for group, trees in items:
if only_group not in [ None, group ]:
continue
for tree in trees:
- if only_aggr_name and only_aggr_name != tree.get("title"):
+ if not is_tree_required(tree):
continue
- aggr_sites = set(x[0] for x in tree.get("reqhosts"))
- if not aggr_sites.intersection(online_sites):
- continue
-
- row = create_aggregation_row(tree)
+ row = create_aggregation_row(tree, status_info)
if row["aggr_state"]["state"] == None:
continue # Not yet monitored, aggregation is not displayed