Module: check_mk
Branch: master
Commit: c3c3c980e524367ebd9b2d1bf6d3371690c9f89d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c3c3c980e52436…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Jul 5 09:49:37 2017 +0200
Fixed access to factory_settings default levels after cmk_base refactoring
Change-Id: I81ea96dc514b232a404097d248476cfed69f1945
---
checks/rmon_stats | 1 +
cmk_base/checks.py | 22 +++++++++++++++++++++-
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/checks/rmon_stats b/checks/rmon_stats
index d580a18..70f49b9 100644
--- a/checks/rmon_stats
+++ b/checks/rmon_stats
@@ -29,6 +29,7 @@
# statistics(1). etherStatsTable(1). etherStatsEntry(1)
# The MIB is called RMON-MIB
+inventory_if_rules = []
def inventory_rmon_stats(info):
settings = host_extra_conf_merged(host_name(), inventory_if_rules)
diff --git a/cmk_base/checks.py b/cmk_base/checks.py
index ba0e41b..7ab93a3 100644
--- a/cmk_base/checks.py
+++ b/cmk_base/checks.py
@@ -143,9 +143,29 @@ def load_checks(filelist):
for check_name in new_checks:
_check_contexts[check_name] = check_context
+ # Collect all variables that the check file did introduce compared to the
+ # default check context
+ new_check_vars = {}
for varname in set(check_context.keys()).difference(known_vars):
- value = check_context[varname]
+ new_check_vars[varname] = check_context[varname]
+
+ # The default_levels_variable of check_info also declares use of a global
+ # variable. Register it here for this context.
+ for check_name in new_checks:
+ # The check_info is not converted yet (convert_check_info()). This means we
need
+ # to deal with old style tuple configured checks
+ if type(check_info[check_name]) == tuple:
+ default_levels_varname = check_default_levels.get(check_name)
+ else:
+ default_levels_varname =
check_info[check_name].get("default_levels_variable")
+
+ if default_levels_varname:
+ new_check_vars[default_levels_varname] = \
+ factory_settings.get(default_levels_varname, {})
+ # Save check variables for e.g. after config loading that the config can
+ # be added to the check contexts
+ for varname, value in new_check_vars.items():
if varname[0] != '_' and type(value) not in ignored_variable_types:
check_variable_defaults[varname] = value