Module: check_mk
Branch: master
Commit: b7f4c0066be9aa6521fe898265d865286859db63
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b7f4c0066be9aa…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Jan 12 13:45:56 2015 +0100
#1808 FIX Fixed broken nagios config when using RBN without a host defined
Check_MK generated a broken configuration where the contact group
'check-mk-notify'
was missing when rule based notifications (RBN) were enabled without a single
host configured.
---
.werks/1808 | 12 ++++++++++++
ChangeLog | 1 +
modules/check_mk.py | 6 +++---
3 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/.werks/1808 b/.werks/1808
new file mode 100644
index 0000000..0248259
--- /dev/null
+++ b/.werks/1808
@@ -0,0 +1,12 @@
+Title: Fixed broken nagios config when using RBN without a host defined
+Level: 1
+Component: core
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1421066674
+
+Check_MK generated a broken configuration where the contact group
'check-mk-notify'
+was missing when rule based notifications (RBN) were enabled without a single
+host configured.
diff --git a/ChangeLog b/ChangeLog
index a7023a6..6ec3de3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,7 @@
* 1792 FIX: Fix path to special agents in case of manual installation
* 1797 FIX: Fix incomplete configuration during checking when using CMC...
* 1832 FIX: Fix "global name 'splitted' is not defined" in bulk
inventory...
+ * 1808 FIX: Fixed broken nagios config when using RBN without a host defined...
Checks & Agents:
* 1665 agent_netapp: New special agent for NetApp monitoring via Web-API...
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 875a1ef..8f40887 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -1866,7 +1866,7 @@ def create_nagios_config(outfile = sys.stdout, hostnames = None):
for hostname in hostnames:
create_nagios_config_host(outfile, hostname)
- create_nagios_config_contacts(outfile)
+ create_nagios_config_contacts(outfile, hostnames)
create_nagios_config_hostgroups(outfile)
create_nagios_config_servicegroups(outfile)
create_nagios_config_contactgroups(outfile)
@@ -2551,7 +2551,7 @@ def create_nagios_config_timeperiods(outfile):
outfile.write(" exclude\t\t\t%s\n" %
",".join(tp["exclude"]))
outfile.write("}\n\n")
-def create_nagios_config_contacts(outfile):
+def create_nagios_config_contacts(outfile, hostnames):
if len(contacts) > 0:
outfile.write("\n#
------------------------------------------------------------\n")
outfile.write("# Contact definitions (controlled by variable
'contacts')\n")
@@ -2600,7 +2600,7 @@ def create_nagios_config_contacts(outfile):
outfile.write(" contactgroups\t\t\t%s\n" % ",
".join(cgrs))
outfile.write("}\n\n")
- if enable_rulebased_notifications:
+ if enable_rulebased_notifications and hostnames:
outfile.write(
"# Needed for rule based notifications\n"
"define contact {\n"