Module: check_mk
Branch: master
Commit: 5c62b03a28fadb41c01858e2754b715d68bc0e70
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5c62b03a28fadb…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Jan 21 14:38:03 2016 +0100
#2944 FIX Fixed exception during config activation having clusters with unresolvable node
IP addresses
---
.werks/2944 | 9 +++++++++
ChangeLog | 1 +
modules/check_mk.py | 24 +++++++++++++++++++-----
3 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/.werks/2944 b/.werks/2944
new file mode 100644
index 0000000..af4723d
--- /dev/null
+++ b/.werks/2944
@@ -0,0 +1,9 @@
+Title: Fixed exception during config activation having clusters with unresolvable node IP
addresses
+Level: 1
+Component: core
+Compatible: compat
+Version: 1.2.7i4
+Date: 1453383432
+Class: fix
+
+
diff --git a/ChangeLog b/ChangeLog
index 6dd77ed..7b675ca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -13,6 +13,7 @@
* 2848 FIX: Fixed cleanup of old autocheck files of cluster hosts...
* 2894 FIX: Fixed broken cluster checks when using Nagios core...
* 2926 FIX: Fix exception in WATO when a check man page has not catalog entry
+ * 2944 FIX: Fixed exception during config activation having clusters with
unresolvable node IP addresses
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 e453a55..5a1d584 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -2020,7 +2020,11 @@ def lookup_ipv4_address(hostname):
def lookup_ipv6_address(hostname):
return lookup_ip_address(hostname, 6)
-# Determine the IP address of a host
+# Determine the IP address of a host. It returns either an IP address,
+# or raise an exception when a hostname can not be resolved on the first
+# try to resolve a hostname. On later tries to resolve a hostname it
+# returns None instead of raising an exception.
+# FIXME: This different handling is bad. Clean this up!
def lookup_ip_address(hostname, family=None):
if family == None: # choose primary family
family = is_ipv6_primary(hostname) and 6 or 4
@@ -3280,11 +3284,21 @@ def get_cluster_attributes(hostname, nodes):
attrs = {}
node_ips_4 = []
if is_ipv4_host(hostname):
- node_ips_4 = [ ip_address_of(h, 4) for h in nodes ]
+ for h in nodes:
+ addr = ip_address_of(h, 4)
+ if addr != None:
+ node_ips_4.append(addr)
+ else:
+ node_ips_4.append(fallback_ip_for(hostname, 4))
node_ips_6 = []
if is_ipv6_host(hostname):
- node_ips_6 = [ ip_address_of(h, 6) for h in nodes ]
+ for h in nodes:
+ addr = ip_address_of(h, 6)
+ if addr != None:
+ node_ips_6.append(addr)
+ else:
+ node_ips_6.append(fallback_ip_for(hostname, 6))
if is_ipv6_primary(hostname):
node_ips = node_ips_6
@@ -3307,8 +3321,8 @@ def ip_address_of(hostname, family=None):
g_failed_ip_lookups.append(hostname)
addr = fallback_ip_for(hostname, family)
if not ignore_ip_lookup_failures:
- configuration_warning("Cannot lookup IP address of '%s': %s,
using "
- "address %s instead" % (hostname, e,
addr))
+ configuration_warning("Cannot lookup IP address of '%s'
(%s). Using "
+ "address %s instead." % (hostname, e,
addr))
return addr