Module: check_mk
Branch: master
Commit: 8c6a968c30daf8917c3e514615ae9ab55621a281
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8c6a968c30daf8…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Aug 28 07:15:23 2017 +0200
Fixed broken (deprecated?) get-autochecks automation
Change-Id: If4561e3c3697a4e39c7b76e3f179acc8baea794b
---
cmk_base/automations/check_mk.py | 3 ++-
cmk_base/discovery.py | 10 ++++++++--
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/cmk_base/automations/check_mk.py b/cmk_base/automations/check_mk.py
index 139ee35..16acced 100644
--- a/cmk_base/automations/check_mk.py
+++ b/cmk_base/automations/check_mk.py
@@ -172,6 +172,7 @@ class AutomationSetAutochecks(DiscoveryAutomation):
automations.register(AutomationSetAutochecks())
+# TODO: Is this automation still needed?
class AutomationGetAutochecks(Automation):
cmd = "get-autochecks"
needs_config = True
@@ -181,7 +182,7 @@ class AutomationGetAutochecks(Automation):
hostname = args[0]
result = []
for ct, item, paramstring in discovery.parse_autochecks_file(hostname):
- result.append((ct, item, eval(paramstring), paramstring))
+ result.append((ct, item, discovery.resolve_paramstring(paramstring),
paramstring))
return result
diff --git a/cmk_base/discovery.py b/cmk_base/discovery.py
index ff3bc79..8e0e142 100644
--- a/cmk_base/discovery.py
+++ b/cmk_base/discovery.py
@@ -1121,6 +1121,12 @@ def _get_cluster_services(hostname, use_caches, with_snmp_scan,
on_error):
return cluster_items
+# Translates a parameter string (read from autochecks) to it's final value
+# (according to the current configuration)
+def resolve_paramstring(paramstring):
+ return eval(paramstring, checks.__dict__, checks.__dict__)
+
+
# Get the list of service of a host or cluster and guess the current state of
# all services if possible
def get_check_preview(hostname, use_caches, do_snmp_scan, on_error):
@@ -1141,7 +1147,7 @@ def get_check_preview(hostname, use_caches, do_snmp_scan,
on_error):
# apply check_parameters
try:
if type(paramstring) == str:
- params = eval(paramstring, checks.__dict__, checks.__dict__)
+ params = resolve_paramstring(paramstring)
else:
params = paramstring
except Exception:
@@ -1230,7 +1236,7 @@ def get_check_preview(hostname, use_caches, do_snmp_scan,
on_error):
perfdata = []
if check_source == "active":
- params = eval(paramstring, checks.__dict__, checks.__dict__)
+ params = resolve_paramstring(paramstring)
if check_source in [ "legacy", "active", "custom"
]:
checkgroup = None