Module: check_mk
Branch: master
Commit: ab0ce98ac248fbbc54197bb14a1d18f99cf1c1d1
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ab0ce98ac248fb…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Jun 26 10:35:27 2015 +0200
keepalive mode: changed variable checking is now performed in verbose mode, not in debug
mode
---
modules/check_mk.py | 32 ++++++++++++++++++++------------
1 file changed, 20 insertions(+), 12 deletions(-)
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 6a1f48b..270b032 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -5245,6 +5245,9 @@ def do_check_keepalive():
num_checks = 0 # count total number of check cycles
read_packed_config()
+
+ # TODO: This is not used at all in keepalive mode except that
compute_check_parameters()
+ # adds variables to this set. But it is not checked in this mode. Should be removed.
global vars_before_config
vars_before_config = set([])
@@ -5253,8 +5256,9 @@ def do_check_keepalive():
global total_check_output
total_check_output = ""
- if opt_debug:
- before = copy_globals()
+
+ if opt_verbose:
+ original_global_vars = copy_globals()
ipaddress_cache = {}
@@ -5268,7 +5272,7 @@ def do_check_keepalive():
read_packed_config()
cleanup_globals()
reset_global_caches()
- before = copy_globals()
+ original_global_vars = copy_globals()
continue
elif not cmdline:
@@ -5360,15 +5364,19 @@ def do_check_keepalive():
cleanup_globals() # Prepare for next check
- # Check if all global variables are clean, but only in debug mode
- if opt_debug:
- after = copy_globals()
- for varname, value in before.items():
- if varname not in ignore_changed_global_variables and value !=
after[varname]:
- sys.stderr.write("WARNING: global variable %s has changed: %r
==> %s\n"
- % (varname, value, repr(after[varname])[:50]))
- new_vars = set(after.keys()).difference(set(before.keys()))
- if (new_vars):
+ # Check if all global variables are clean, but only in verbose logging mode
+ if opt_verbose:
+ new_global_vars = copy_globals()
+ for varname, value in original_global_vars.items():
+ if varname not in ignore_changed_global_variables and value !=
new_global_vars[varname]:
+ if opt_verbose > 1:
+ sys.stderr.write("WARNING: global variable %s has changed:
%r ==> %r\n"
+ % (varname, value, new_global_vars[varname]))
+ else:
+ sys.stderr.write("WARNING: global variable %s has changed:
%s ==> %s\n"
+ % (varname, repr(value)[:50],
repr(new_global_vars[varname])[:50]))
+ new_vars =
set(new_global_vars.keys()).difference(set(original_global_vars.keys()))
+ if new_vars:
sys.stderr.write("WARNING: new variable appeared: %s\n" %
", ".join(new_vars))
sys.stderr.flush()