Module: check_mk
Branch: master
Commit: 60fa01b5f729be2765c8f055baf843bce2410d07
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=60fa01b5f729be…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sun Feb 7 21:28:42 2016 +0100
#3168 FIX Fix duplicate loading of check that have a copy in local/share/check_mk/checks.
---
.bugs/2382 | 8 ++++++--
.werks/3168 | 9 +++++++++
ChangeLog | 1 +
modules/check_mk.py | 25 +++++++++++++++----------
4 files changed, 31 insertions(+), 12 deletions(-)
diff --git a/.bugs/2382 b/.bugs/2382
index bc08146..dc8f492 100644
--- a/.bugs/2382
+++ b/.bugs/2382
@@ -1,10 +1,14 @@
Title: If check files are available in local, we must not read in those in share!
Component: core
-State: open
+Class: bug
+State: done
Date: 2015-10-27 17:14:55
Targetversion: 1.2.8
-Class: bug
When creating precompiled Nagios files this is already exactly the implemented
behaviour. But when you run cmk -v or CMC then *both* files are being read.
This can lead to a different (wrong) behaviour.
+
+2016-02-07 21:28:09: changed state open -> done
+We now read first the files from local. The we skip files already
+read.
diff --git a/.werks/3168 b/.werks/3168
new file mode 100644
index 0000000..102487f
--- /dev/null
+++ b/.werks/3168
@@ -0,0 +1,9 @@
+Title: Fix duplicate loading of check that have a copy in local/share/check_mk/checks.
+Level: 1
+Component: core
+Compatible: compat
+Version: 1.2.7i4
+Date: 1454876897
+Class: fix
+
+
diff --git a/ChangeLog b/ChangeLog
index 68e6c7b..8e58929 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -17,6 +17,7 @@
* 2944 FIX: Fixed exception during config activation having clusters with
unresolvable node IP addresses
* 3037 FIX: Terminate datasource programs when check timeout occurs...
* 2932 FIX: Removal of duplicate services now also works for hosts that are no longer
SNMP+TCP
+ * 3168 FIX: Fix duplicate loading of check that have a copy in
local/share/check_mk/checks.
Checks & Agents:
* 2434 NetApp monitoring: Cluster-Mode is now supported, changes in existing 7Mode
checks...
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 5b249b9..7c9a77e 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -382,10 +382,11 @@ special_agent_info = {}
# Now read in all checks. Note: this is done *before* reading the
# configuration, because checks define variables with default
# values user can override those variables in his configuration.
-# Do not read in the checks if check_mk is called as module
+# If a check or check.include is both found in local/ and in the
+# normal structure, then only the file in local/ must be read!
def load_checks():
- filelist = plugin_pathnames_in_directory(checks_dir) \
- + plugin_pathnames_in_directory(local_checks_dir)
+ filelist = plugin_pathnames_in_directory(local_checks_dir) \
+ + plugin_pathnames_in_directory(checks_dir)
# read include files always first, but still in the sorted
# order with local ones last (possibly overriding variables)
@@ -398,15 +399,19 @@ def load_checks():
known_vars = set(globals().keys()) # track new configuration variables
+ loaded_files = set()
for f in filelist:
if not f.endswith("~"): # ignore emacs-like backup files
- try:
- execfile(f, globals())
- except Exception, e:
- sys.stderr.write("Error in plugin file %s: %s\n" % (f, e))
- if opt_debug:
- raise
- sys.exit(5)
+ file_name = f.rsplit("/", 1)[-1]
+ if file_name not in loaded_files:
+ try:
+ loaded_files.add(file_name)
+ execfile(f, globals())
+ except Exception, e:
+ sys.stderr.write("Error in plugin file %s: %s\n" % (f, e))
+ if opt_debug:
+ raise
+ sys.exit(5)
for varname, value in globals().iteritems():
if varname[0] != '_' \