Module: check_mk
Branch: master
Commit: f939b8dae7fb810e66ba0101510e6002d9215392
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f939b8dae7fb81…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Apr 27 11:12:22 2015 +0200
Conflicts:
ChangeLog
modules/check_mk.py
---
.werks/2243 | 10 ++++++++++
ChangeLog | 1 +
modules/automation.py | 6 +++---
modules/check_mk.py | 23 ++++++++++++-----------
4 files changed, 26 insertions(+), 14 deletions(-)
diff --git a/.werks/2243 b/.werks/2243
new file mode 100644
index 0000000..cce7619
--- /dev/null
+++ b/.werks/2243
@@ -0,0 +1,10 @@
+Title: Check_MK notifications don't fail anymore when duplicate hosts are configured
+Level: 1
+Component: notifications
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1430125860
+
+
diff --git a/ChangeLog b/ChangeLog
index 46960a0..70112e3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -486,6 +486,7 @@
* 2081 FIX: Improved logging of mkeventd in error cases
* 2193 FIX: Remove duplicate performance data from host notifications...
* 2207 FIX: Fix exception in rule based notifiations with Nagios core and event type
filter...
+ * 2243 FIX: Check_MK notifications don't fail anymore when duplicate hosts are
configured
BI:
* 1784 FIX: Fix exception in BI Boxes when parents are being used
diff --git a/modules/automation.py b/modules/automation.py
index 294bac6..8b03447 100644
--- a/modules/automation.py
+++ b/modules/automation.py
@@ -34,17 +34,17 @@ class MKAutomationError(Exception):
def do_automation(cmd, args):
try:
if cmd == "get-configuration":
- read_config_files(with_autochecks=False, with_conf_d=False)
+ read_config_files(with_conf_d=False)
result = automation_get_configuration()
elif cmd == "get-check-information":
result = automation_get_check_information()
elif cmd == "delete-host":
- read_config_files(with_autochecks=False)
+ read_config_files()
result = automation_delete_host(args)
elif cmd == "notification-get-bulks":
result = automation_get_bulks(args)
elif cmd == "update-dns-cache":
- read_config_files(with_autochecks=False)
+ read_config_files()
result = automation_update_dns_cache()
else:
read_config_files()
diff --git a/modules/check_mk.py b/modules/check_mk.py
index dc294e7..6d937a5 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -5420,7 +5420,7 @@ def interactive_abort(error):
sys.stderr.write(error + "\n")
sys.exit(1)
-def read_config_files(with_autochecks=True, with_conf_d=True):
+def read_config_files(with_conf_d=True, validate_hosts=True):
global vars_before_config, final_mk, local_mk, checks
# Initialize dictionary-type default levels variables
@@ -5479,13 +5479,14 @@ def read_config_files(with_autochecks=True, with_conf_d=True):
collect_hosttags()
- # Sanity check for duplicate hostnames
- seen_hostnames = set([])
- for hostname in all_active_hosts():
- if hostname in seen_hostnames:
- sys.stderr.write("Error in configuration: duplicate host
'%s'\n" % hostname)
- sys.exit(3)
- seen_hostnames.add(hostname)
+ if validate_hosts:
+ # Sanity check for duplicate hostnames
+ seen_hostnames = set([])
+ for hostname in all_active_hosts():
+ if hostname in seen_hostnames:
+ sys.stderr.write("Error in configuration: duplicate host
'%s'\n" % hostname)
+ sys.exit(3)
+ seen_hostnames.add(hostname)
# Add WATO-configured explicit checks to (possibly empty) checks
# statically defined in checks.
@@ -5901,15 +5902,15 @@ try:
do_inv_check(a)
done = True
elif o == '--notify':
- read_config_files(False, True)
+ read_config_files(with_conf_d=True, validate_hosts=False)
sys.exit(do_notify(args))
elif o == '--create-rrd':
- read_config_files(False, True)
+ read_config_files(with_conf_d=True)
execfile(modules_dir + "/rrd.py")
do_create_rrd(args)
done = True
elif o == '--convert-rrds':
- read_config_files(False, True)
+ read_config_files(with_conf_d=True)
execfile(modules_dir + "/rrd.py")
do_convert_rrds(args)
done = True