Module: check_mk
Branch: master
Commit: fec8bb40437c9cd4c533ec5bc8939e8307afae0a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=fec8bb40437c9c…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sun Apr 29 08:35:25 2012 +0200
make host_extra_conf["parents"] have precedence
---
ChangeLog | 3 +++
modules/check_mk.py | 10 +++++++---
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e4fdc4d..6cb2349 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,9 @@
Core:
* FIX: fixed SNMP info declaration in checks: could be garbled
up in rare cases
+ * avoid duplicate parents definition, when using 'parents' and
+ extra_host_conf["parents"] at the same time. The later one has
+ precedence.
Multisite:
* Logwatch: Colorizing OK state blocks correctly
diff --git a/modules/check_mk.py b/modules/check_mk.py
index a1b0c66..4243f45 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -1507,8 +1507,12 @@ def create_nagios_hostdefs(outfile, hostname):
outfile.write(" contact_groups\t\t%s\n" % ",".join(cgrs))
contactgroups_to_define.update(cgrs)
+ # Get parents manually defined via extra_host_conf["parents"]. Only honor
+ # variable "parents" and implicit parents if this setting is empty
+ extra_conf_parents = host_extra_conf(hostname,
extra_host_conf.get("parents", []))
+
# Parents for non-clusters
- if not is_clust:
+ if not extra_conf_parents and not is_clust:
parents_list = parents_of(hostname)
if len(parents_list) > 0:
outfile.write(" parents\t\t\t%s\n" %
(",".join(parents_list)))
@@ -1522,13 +1526,13 @@ def create_nagios_hostdefs(outfile, hostname):
node_ips = [ lookup_ipaddress(h) for h in nodes ]
alias = "cluster of %s" % ", ".join(nodes)
outfile.write(" _NODEIPS\t\t\t%s\n" % " ".join(node_ips))
- outfile.write(" parents\t\t\t%s\n" % ",".join(nodes))
+ if not extra_conf_parents:
+ outfile.write(" parents\t\t\t%s\n" % ",".join(nodes))
# Host check uses (service-) IP address if available
if ip:
outfile.write(" check_command\t\t\tcheck-mk-ping\n")
-
# Output alias, but only if it's not define in extra_host_conf
aliases = host_extra_conf(hostname, extra_host_conf.get("alias", []))
if len(aliases) == 0: