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()
Module: check_mk
Branch: master
Commit: 670d45b7532cc197dec71538b99aba84eb94ca2c
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=670d45b7532cc1…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Jun 26 10:33:42 2015 +0200
Excluding normally changing vars during checking from changed vars check
---
modules/check_mk.py | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 755818a..6a1f48b 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -5364,7 +5364,7 @@ def do_check_keepalive():
if opt_debug:
after = copy_globals()
for varname, value in before.items():
- if value != after[varname]:
+ 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()))
@@ -5411,6 +5411,13 @@ def keepalive_read_line():
# | Code for reading the configuration files. |
# '----------------------------------------------------------------------'
+# These variables shal be ignored when performing checks which global
+# variables have been changed during runtime of e.g. the Check_MK
+# keepalive mode
+ignore_changed_global_variables = [
+ 'all_hosts_untagged',
+ 'all_clusters_untagged',
+]
# Now - at last - we can read in the user's configuration files
def all_nonfunction_vars():
@@ -5564,8 +5571,7 @@ def read_config_files(with_conf_d=True, validate_hosts=True):
vars_after_config = all_nonfunction_vars()
ignored_variables = set(['vars_before_config', 'parts',
'hosttags' ,'seen_hostnames',
- 'all_hosts_untagged', 'all_clusters_untagged',
- 'taggedhost' ,'hostname'])
+ 'taggedhost' ,'hostname'] + ignore_changed_global_variables)
errors = 0
for name in vars_after_config:
if name not in ignored_variables and name not in vars_before_config:
Module: check_mk
Branch: master
Commit: bd7617fbe9cc12b75cfcac92abee4ed11698285e
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bd7617fbe9cc12…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Jun 26 08:40:54 2015 +0200
#2344 FIX Improved validation of selected rules when editing BI aggregations
In previous versions it was possible to create a non working BI configuration
using the BI editor by creating an aggregation which calls a BI rules which
needs one or several arguments, but not providing any argument in the BI aggregation.
Saving this configuration was possible and caused problems in different places
of the GUI, for example the report editor when rendering the BI filters.
The editor has been extended to do a better validation to prevent this kind of
misconfiguration.
---
.werks/2344 | 17 +++++++++++++++++
ChangeLog | 3 +++
web/htdocs/wato.py | 15 ++++++++++++++-
3 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/.werks/2344 b/.werks/2344
new file mode 100644
index 0000000..1ac61d3
--- /dev/null
+++ b/.werks/2344
@@ -0,0 +1,17 @@
+Title: Improved validation of selected rules when editing BI aggregations
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i3
+Date: 1435300730
+
+In previous versions it was possible to create a non working BI configuration
+using the BI editor by creating an aggregation which calls a BI rules which
+needs one or several arguments, but not providing any argument in the BI aggregation.
+Saving this configuration was possible and caused problems in different places
+of the GUI, for example the report editor when rendering the BI filters.
+
+The editor has been extended to do a better validation to prevent this kind of
+misconfiguration.
diff --git a/ChangeLog b/ChangeLog
index 79d1fb3..129bb11 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,9 @@
Multisite:
* 2314 FIX: Availability: fixed exception when grouping by host or service group
+ WATO:
+ * 2344 FIX: Improved validation of selected rules when editing BI aggregations...
+
Notifications:
* 2313 FIX: notification bulking: fixed exception for plugins which are not configured with checkboxes, e.g. sms
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index f3736fe..c7a256d 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -16980,6 +16980,18 @@ def convert_aggregation_to_bi(aggr):
convaggr = (bi_constants["DISABLED"],) + convaggr
return convaggr
+
+def validate_bi_rule_call(value, varprefix):
+ rule_id, arguments = value
+ aggregations, aggregation_rules = load_bi_rules()
+ rule_params = aggregation_rules[rule_id]['params']
+
+ if len(arguments) != len(rule_params):
+ raise MKUserError(varprefix+"_1_0", _("The rule you selected needs %d argument(s) (%s), "
+ "but you configured %d arguments.") %
+ (len(rule_params), ', '.join(rule_params), len(arguments)))
+
+
# Not in global context, so that l10n will happen again
def declare_bi_valuespecs(aggregation_rules):
global vs_aggregation, aggregation_choices, vs_bi_node
@@ -17002,7 +17014,8 @@ def declare_bi_valuespecs(aggregation_rules):
size = 12,
title = _("Arguments:"),
),
- ]
+ ],
+ validate = validate_bi_rule_call,
)
host_re_help = _("Either an exact host name or a regular expression exactly matching the host "