Module: check_mk
Branch: master
Commit: 9d81359a199ed7e54ba2f94013fecaae0879163f
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9d81359a199ed7…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Mar 1 12:15:36 2013 +0100
FIX: list of BI aggregates was incomplete in some cases
---
ChangeLog | 3 +-
web/htdocs/bi.py | 61 +++++++++++++++++++++++++++++++-----------------------
2 files changed, 37 insertions(+), 27 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 8062d53..2c84343 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -51,8 +51,8 @@
* FIX: no default PING service if custom checks are defined
* FIX: check_mk_base: fixed rounding error in get_bytes_human_readable
* FIX: check_mk: improved support of utf-8 characters in extra_service_conf
- * New configuration variable contactgroup_members
* FIX: livestatus: table statehist now able to check AuthUser permissions
+ * New configuration variable contactgroup_members
Checks & Agents:
* FIX: smart - not trying to parse unhandled lines to prevent errors
@@ -88,6 +88,7 @@
* FIX: fix exception in top/down and bottom/up views
* FIX: fix styling of top/down and bottom/up views (borders, padding)
* FIX: fix style of mouse pointer over BI boxes
+ * FIX: list of BI aggregates was incomplete in some cases
* Make titles of non-leaf tree nodes klickable
WATO:
diff --git a/web/htdocs/bi.py b/web/htdocs/bi.py
index 671410d..3e2de1a 100644
--- a/web/htdocs/bi.py
+++ b/web/htdocs/bi.py
@@ -121,7 +121,6 @@ NT_PLACEHOLDER = 4 # temporary dummy entry needed for REMAINING
g_cache = {} # per-user cache
g_config_information = None # for invalidating cache after config change
did_compilation = False # Is set to true if anything has been compiled
-g_compiled_everything = False # Is set to true if all aggregations have been compiled
# Load the static configuration of all services and hosts (including tags)
# without state.
@@ -211,47 +210,57 @@ def log(s):
# aggregation functions are still left as names. That way the forest
# printable (and storable in Python syntax to a file).
def compile_forest(user, only_hosts = None, only_groups = None):
- global g_cache, g_user_cache, g_compiled_everything
+ global g_cache, g_user_cache
global used_cache, did_compilation
new_config_information = cache_needs_update()
- if new_config_information \
- or (config.bi_precompile_on_demand and not only_groups and not only_hosts):
- # config changed or monitoring daemon restarted, clear cache.
- # or: in case of on demand precompile and a total compilation
- # requested (even if some hosts have already be compiled).
+ if new_config_information:
+ log("Configuration has changed. Forcing recompile.\n")
g_cache = {}
global g_config_information
g_config_information = new_config_information
- g_compiled_everything = False
-
- if g_compiled_everything:
- log('PID: %d - Already compiled everything\n' % os.getpid())
- used_cache = True
- return # In this case simply skip further compilations
# OPTIMIZE: All users that have the permissing bi.see_all
# can use the same cache.
if config.may("bi.see_all"):
user = '<<<see_all>>>'
- # Try to get data from per-user cache:
- # make sure, BI permissions have not changed since last time
- cache = g_cache.get(user)
- if cache and cache["see_all"] == config.may("bi.see_all"):
- g_user_cache = cache
- else:
- # Initialize empty caching structure
- cache = {
+ def empty_user_cache():
+ return {
"forest" : {},
"aggregations_by_hostname" : {},
"host_aggregations" : {},
"affected_hosts" : {},
"affected_services": {},
- "see_all" : config.may("bi.see_all"),
"compiled_hosts" : set([]),
- "compiled_groups": set([]),
+ "compiled_groups" : set([]),
+ "compiled_all" : False,
}
+
+ # Try to get data from per-user cache:
+ # make sure, BI permissions have not changed since last time.
+ # g_user_cache is a global variable for all succeeding functions, so
+ # that they do not need to check the user again
+ cache = g_cache.get(user)
+ if cache:
+ g_user_cache = cache
+ else:
+ # Initialize empty caching structure
+ cache = empty_user_cache()
+ g_user_cache = cache
+
+ if g_user_cache["compiled_all"]:
+ log('PID: %d - Already compiled everything\n' % os.getpid())
+ used_cache = True
+ return # In this case simply skip further compilations
+
+ # If we have previously only partly compiled and now there is no
+ # filter, then throw away partly compiled data.
+ if (cache["compiled_hosts"] or cache["compiled_groups"]) \
+ and (not config.bi_precompile_on_demand \
+ or (config.bi_precompile_on_demand and not only_groups and not only_hosts)):
+ log("Invalidating incomplete cache, since we compile all now.\n")
+ cache = empty_user_cache()
g_user_cache = cache
# Reduces a list of hosts by the already compiled hosts
@@ -395,8 +404,7 @@ def compile_forest(user, only_hosts = None, only_groups = None):
# The list of ALL hosts
cache['compiled_hosts'] = set(g_services.keys())
cache['compiled_groups'] = set(cache['forest'].keys())
-
- g_compiled_everything = True
+ cache['compiled_all'] = True
# Remember successful compile in cache
g_cache[user] = cache
@@ -436,7 +444,7 @@ def compile_forest(user, only_hosts = None, only_groups = None):
num_new_multi_aggrs, num_new_host_aggrs,
only_groups and len(only_groups) or 0,
- g_compiled_everything,
+ cache['compiled_all'],
num_total_aggr - num_host_aggr,
num_host_aggr,
len(cache['compiled_groups']),
@@ -1701,6 +1709,7 @@ def singlehost_table(columns, add_headers, only_sites, limit,
filters, joinbynam
host_columns = filter(lambda c: c.startswith("host_"), columns)
hostrows = get_status_info_filtered(filter_code, only_sites, limit, host_columns,
config.bi_precompile_on_demand)
+
# if limit:
# views.check_limit(hostrows, limit)