Module: check_mk
Branch: master
Commit: 7f25de14d9033617416211dd489f760eab9162e8
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7f25de14d90336…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Sep 29 09:15:33 2014 +0200
#1408 FIX mknotifyd now really reads all configuration files below mknotifyd.d
Previously the notification spooler daemon <tt>mknotifyd</tt> just read the
single file <tt>etc/check_mk/mknotifyd.d/wato/global.mk</tt>. Now it reads
all files below <tt>etc/check_mk/mknotifyd.d</tt> - just as one would
expect. Note: there is still no <tt>etc/check_mk/mknotifyd.mk</tt> file.
---
.werks/1408 | 12 ++++++++++++
ChangeLog | 1 +
doc/treasures/mknotifyd | 26 ++++++++++++++++++++++++--
3 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/.werks/1408 b/.werks/1408
new file mode 100644
index 0000000..fa7fc02
--- /dev/null
+++ b/.werks/1408
@@ -0,0 +1,12 @@
+Title: mknotifyd now really reads all configuration files below mknotifyd.d
+Level: 2
+Component: notifications
+Compatible: compat
+Version: 1.2.5i6
+Date: 1411974839
+Class: fix
+
+Previously the notification spooler daemon <tt>mknotifyd</tt> just read the
+single file <tt>etc/check_mk/mknotifyd.d/wato/global.mk</tt>. Now it reads
+all files below <tt>etc/check_mk/mknotifyd.d</tt> - just as one would
+expect. Note: there is still no <tt>etc/check_mk/mknotifyd.mk</tt> file.
diff --git a/ChangeLog b/ChangeLog
index 1ab5d69..4795829 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -136,6 +136,7 @@
* 1156 FIX: Graphs in HTML mails are now sent again where they where missing...
* 1157 FIX: Fixed SMS plugin on at least debian (distrs which have no
sendsms/smssend)...
* 1407 FIX: Fix exception in rule based notification on non-Ascii characters in log
message
+ * 1408 FIX: mknotifyd now really reads all configuration files below mknotifyd.d...
BI:
* 1406 Assume PEND in count_ok aggregations if all nodes are PEND...
diff --git a/doc/treasures/mknotifyd b/doc/treasures/mknotifyd
index 44cca4c..0a793d8 100755
--- a/doc/treasures/mknotifyd
+++ b/doc/treasures/mknotifyd
@@ -352,9 +352,16 @@ def daemonize(user=0, group=0):
def load_configuration():
global g_config, g_config_changed
last_config = g_config.copy()
- config_file = "%s/mknotifyd.d/wato/global.mk" % g_config_dir
+ config_dir = "%s/mknotifyd.d" % g_config_dir
+
try:
- execfile(config_file, {}, g_config)
+ 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(config_dir) ], [])
+ list_of_files.sort(cmp = cmp_config_paths)
+ for path in list_of_files:
+ verbose("Reading configuration file %s" % path)
+ execfile(path, {}, g_config)
except:
g_config = last_config
@@ -362,6 +369,21 @@ def load_configuration():
log("Configuration has changed")
g_config_changed = True
+# This function has been stolen from check_mk.py.
+# Helper function 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 usage():
sys.stdout.write("""Usage: mknotifyd [OPTIONS]