Module: check_mk
Branch: master
Commit: f9238743ec4db3b6f67f48cb50cea8624ebbc88b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f9238743ec4db3…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Jan 22 10:17:27 2015 +0100
#1875 FIX Fixed possible exceptions of CMC Check_MK helpers when using some custom checks
When using the CMC together with some custom checks which register variables
in the global context which can not be written out with repr() and read with
eval() like for example python module references or function pointers, all
Check_MK workers stopped working and were restarting in an endless loop.
A verification has been added to prevent those variable from being written
to the Check_MK check helper config var/check_mk/core/config.mk.
---
.werks/1875 | 16 ++++++++++++++++
ChangeLog | 1 +
modules/check_mk.py | 20 ++++++++++++++++----
3 files changed, 33 insertions(+), 4 deletions(-)
diff --git a/.werks/1875 b/.werks/1875
new file mode 100644
index 0000000..4c18162
--- /dev/null
+++ b/.werks/1875
@@ -0,0 +1,16 @@
+Title: Fixed possible exceptions of CMC Check_MK helpers when using some custom checks
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1421918120
+
+When using the CMC together with some custom checks which register variables
+in the global context which can not be written out with repr() and read with
+eval() like for example python module references or function pointers, all
+Check_MK workers stopped working and were restarting in an endless loop.
+
+A verification has been added to prevent those variable from being written
+to the Check_MK check helper config var/check_mk/core/config.mk.
diff --git a/ChangeLog b/ChangeLog
index ab7d841..137e94a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -100,6 +100,7 @@
* 1671 FIX: windows agent: fixed gaps in eventlog monitoring after agent restart...
* 1856 FIX: ibm_svc_array ibm_svc_mdisk ibm_svc_mdiskgrp ibm_svc_portfc: made checks
more robust for varying number of parameters of IBM SVC agent plugin...
* 1874 FIX: ps: Old process inventory configurations work now again...
+ * 1875 FIX: Fixed possible exceptions of CMC Check_MK helpers when using some custom
checks...
Multisite:
* 1758 Improved exception hander: Shows details without additional debug request,
added mailto link for error report...
diff --git a/modules/check_mk.py b/modules/check_mk.py
index d52e6bd..89a23ac 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -2967,13 +2967,25 @@ no_inventory_possible = None
# the running system.
derived_config_variable_names = [ "hosttags", "all_hosts_untagged" ]
def pack_config():
+ # Checks whether or not a variable can be written to the config.mk
+ # and read again from it.
+ def packable(varname, val):
+ if type(val) in [ int, str, unicode, bool ] or not val:
+ return True
+
+ try:
+ eval(repr(val))
+ return True
+ except:
+ return False
+
filepath = var_dir + "/core/config.mk"
out = file(filepath + ".new", "w")
out.write("#!/usr/bin/python\n# encoding: utf-8\n# Created by Check_MK. Dump of
the currently active configuration\n\n")
- for varname in config_variable_names:
- out.write("\n%s = %r\n" % (varname, globals()[varname]))
- for varname in derived_config_variable_names:
- out.write("\n%s = %r\n" % (varname, globals()[varname]))
+ for varname in list(config_variable_names) + derived_config_variable_names:
+ val = globals()[varname]
+ if packable(varname, val):
+ out.write("\n%s = %r\n" % (varname, val))
for varname, factory_setting in factory_settings.items():
if varname in globals():
out.write("\n%s = %r\n" % (varname, globals()[varname]))