Module: check_mk
Branch: master
Commit: ffd8da5930f2abb85f02b5470dde5184f1f00f76
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ffd8da5930f2ab…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Jul 2 16:17:17 2012 +0200
FIX: Precisely define order of reading of configuration files.
---
ChangeLog | 2 ++
modules/check_mk.py | 19 ++++++++++++++++++-
2 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d58677d..ea14d5b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,8 @@
Core:
* simulation_mode: legacy_checks, custom_checks and active_checks
are replaced with dummy checks always being OK
+ * FIX: Precisely define order of reading of configuration files. This
+ fixes a WATO rule precedence problem
Checks & Agents:
* FIX: Fixed syntax errors in a bunch of man pages
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 2c5725a..8f9dbe9 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -4229,6 +4229,22 @@ def marks_hosts_with_path(old, all, filename):
if host not in old:
host_paths[host] = path
+# Helper functions that determines the sort order of the
+# configuration files. The following two rules are implemented:
+# 1. *.mk files in the same directory will be read
+# according to their lexical order.
+# 2. subdirectories in the same directory will be
+# scanned according to their lexical order.
+# 3. subdirectories of a directory will always be read *after*
+# the *.mk files in that directory.
+def cmp_config_paths(a, b):
+ pa = a.split('/')
+ pb = b.split('/')
+ return cmp(pa[:-1], pb[:-1]) or \
+ cmp(len(pa), len(pb)) or \
+ cmp(pa, pb)
+
+
def read_config_files(with_autochecks=True, with_conf_d=True):
global vars_before_config, final_mk, local_mk, checks
@@ -4243,7 +4259,8 @@ def read_config_files(with_autochecks=True, with_conf_d=True):
list_of_files = reduce(lambda a,b: a+b,
[ [ "%s/%s" % (d, f) for f in fs if f.endswith(".mk")]
for d, sb, fs in os.walk(check_mk_configdir) ], [])
- list_of_files.sort()
+ # list_of_files.sort()
+ list_of_files.sort(cmp = cmp_config_paths)
list_of_files = [ check_mk_configfile ] + list_of_files
else:
list_of_files = [ check_mk_configfile ]