Module: check_mk
Branch: master
Commit: 0afeed9eb46a2e310454e9dc554eb8b35d6881e0
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0afeed9eb46a2e…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Mon May 7 14:10:35 2018 +0200
5804 FIX BI aggregations: increased render performance
The livestatus data required for rendering the BI tree is no longer fetched consecutive
from one site after another.
The new mechanism queries all sites in parallel, hereby increasing the livestatus query
performance.
Change-Id: I022516125d28d58da93c7d47648c2e8d5db67fa3
---
.werks/5804 | 12 ++++++++++++
web/htdocs/bi.py | 50 ++++++++++++++++++++++++--------------------------
2 files changed, 36 insertions(+), 26 deletions(-)
diff --git a/.werks/5804 b/.werks/5804
new file mode 100644
index 0000000..a2a51cd
--- /dev/null
+++ b/.werks/5804
@@ -0,0 +1,12 @@
+Title: BI aggregations: increased render performance
+Level: 1
+Component: bi
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1525694777
+
+The livestatus data required for rendering the BI tree is no longer fetched consecutive
from one site after another.
+The new mechanism queries all sites in parallel, hereby increasing the livestatus query
performance.
diff --git a/web/htdocs/bi.py b/web/htdocs/bi.py
index ca5cfb8..9c93275 100644
--- a/web/htdocs/bi.py
+++ b/web/htdocs/bi.py
@@ -2483,33 +2483,31 @@ def execute_rule_node(node, status_info, aggregation_options):
# a known lists of lists (list of site/host pairs)
def get_status_info(required_hosts):
# Query each site only for hosts that that site provides
- site_hosts = {}
+ req_hosts = set()
+ req_sites = set()
+
for site, host in required_hosts:
- hosts = site_hosts.get(site)
- if hosts == None:
- site_hosts[site] = [host]
- else:
- hosts.append(host)
-
- tuples = []
- for site, hosts in site_hosts.iteritems():
- filter = ""
- for host in hosts:
- filter += "Filter: name = %s\n" % host
- if len(hosts) > 1:
- filter += "Or: %d\n" % len(hosts)
- sites.live().set_auth_domain('bi')
- sites.live().set_only_sites([site])
- data = sites.live().query(
- "GET hosts\n"
- "Columns: name state hard_state plugin_output
scheduled_downtime_depth "
- "acknowledged in_service_period services_with_fullstate\n"
- + filter)
- sites.live().set_auth_domain('read')
- sites.live().set_only_sites(None)
- tuples += [((site, e[0]), e[1:]) for e in data]
-
- return dict(tuples)
+ req_hosts.add(host)
+ req_sites.add(site)
+
+ host_filter = ""
+ for host in req_hosts:
+ host_filter += "Filter: name = %s\n" % host
+ if len(req_hosts) > 1:
+ host_filter += "Or: %d\n" % len(req_hosts)
+ sites.live().set_auth_domain('bi')
+ sites.live().set_only_sites(list(req_sites))
+ sites.live().set_prepend_site(True)
+ data = sites.live().query(
+ "GET hosts\n"
+ "Columns: name state hard_state plugin_output scheduled_downtime_depth
"
+ "acknowledged in_service_period services_with_fullstate\n"
+ + host_filter)
+ sites.live().set_auth_domain('read')
+ sites.live().set_only_sites(None)
+ sites.live().set_prepend_site(False)
+ return dict([((e[0], e[1]), e[2:]) for e in data])
+
# This variant of the function is configured not with a list of
# hosts but with a livestatus filter header and a list of columns