Module: check_mk
Branch: master
Commit: dd56f2b31e57210326371a63565ed46a249a7484
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=dd56f2b31e5721…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sun Oct 24 22:37:11 2010 +0200
cluster host check: use service IP if available
---
ChangeLog | 2 ++
modules/check_mk.py | 10 +++++++---
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 031b037..3da991f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,8 @@
Core, Setup, etc.:
* setup.sh: turn off Python debugging
* Cleaned up documentation directory
+ * cluster host: use real IP address for host check if cluster has
+ one (e.g. service IP address)
Checks & Agents:
* Added missing PNP template for check_mk-hr_cpu
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 0961e18..8a69f09 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -1169,7 +1169,7 @@ def create_nagios_hostdefs(outfile, hostname):
except:
if not is_cluster(hostname):
raise MKGeneralException("Cannot determine ip address of %s. Please add
to ipaddresses." % hostname)
- ip = "0.0.0.0"
+ ip = None
# _
# / |
@@ -1181,7 +1181,7 @@ def create_nagios_hostdefs(outfile, hostname):
outfile.write("\ndefine host {\n")
outfile.write(" host_name\t\t\t%s\n" % hostname)
outfile.write(" use\t\t\t\t%s\n" % (is_clust and cluster_template or
host_template))
- outfile.write(" address\t\t\t%s\n" % ip)
+ outfile.write(" address\t\t\t%s\n" % (ip and ip or "0.0.0.0"))
outfile.write(" _TAGS\t\t\t\t%s\n" % "
".join(tags_of_host(hostname)))
# Host groups: If the host has no hostgroups it gets the default
@@ -1219,6 +1219,10 @@ def create_nagios_hostdefs(outfile, hostname):
outfile.write(" _NODEIPS\t\t\t%s\n" % " ".join(node_ips))
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")
+
outfile.write(" alias\t\t\t\t%s\n" % alias)
# Custom configuration last -> user may override all other values
@@ -1237,7 +1241,7 @@ def create_nagios_hostdefs(outfile, hostname):
outfile.write(" host_name\t\t\t%s\n" % summary_hostname(hostname))
outfile.write(" use\t\t\t\t%s-summary\n" % (is_clust and
cluster_template or host_template))
outfile.write(" alias\t\t\t\tSummary of %s\n" % alias)
- outfile.write(" address\t\t\t%s\n" % ip)
+ outfile.write(" address\t\t\t%s\n" % (ip and ip or
"0.0.0.0"))
outfile.write(" _TAGS\t\t\t\t%s\n" % "
".join(tags_of_host(hostname)))
outfile.write(" __REALNAME\t\t\t%s\n" % hostname)
outfile.write(" parents\t\t\t%s\n" % hostname)