Module: check_mk
Branch: master
Commit: ab8b6c6565e787df7984f859c1c9876171fe12e5
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ab8b6c6565e787…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sat Nov 5 12:08:46 2011 +0100
Handle None-parameter for checks with factory_settings
If a check created by inventory has None as a parameter
but for that check type exists factory settings, then
we automatically change the None into an empty dictionary
so that the factory settings will apply. This helps in
cases where an earlier version of the check works without
parameters and a later implementation uses a dictionary.
---
modules/check_mk.py | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 5162bd8..b03f8aa 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -4110,6 +4110,21 @@ def compute_check_parameters(host, checktype, item, params):
def_levels_varname = check_default_levels.get(checktype)
if def_levels_varname:
vars_before_config.add(def_levels_varname)
+
+ # Handle case where parameter is None but the type of the
+ # default value is a dictionary. This is for example the
+ # case if a check type has gotten parameters in a new version
+ # but inventory of the old version left None as a parameter.
+ # Also from now on we support that the inventory simply puts
+ # None as a parameter. We convert that to an empty dictionary
+ # that will be updated with the factory settings and default
+ # levels, if possible.
+ if params == None and def_levels_varname:
+ fs = factory_settings.get(def_levels_varname)
+ if type(fs) == dict:
+ params = {}
+
+ # Honor factory settings for dict-type checks
if def_levels_varname and type(params) == dict:
# Start with factory settings
@@ -4133,7 +4148,6 @@ def compute_check_parameters(host, checktype, item, params):
# Get parameters configured via check_parameters
entries += service_extra_conf(host, descr, check_parameters)
-
if len(entries) > 0:
# loop from last to first (first must have precedence)
for entry in entries[::-1]: