Module: check_mk
Branch: master
Commit: ec31d4b85ced81a4f225c5693ebe19aa81faa9c6
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ec31d4b85ced81…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Feb 20 15:33:12 2015 +0100
#2012 FIX Piggyback hostname translation can now deal correctly with umlauts
---
.werks/2012 | 10 ++++++++++
ChangeLog | 1 +
checks/esx_vsphere_datastores | 1 +
modules/check_mk_base.py | 8 ++++++--
4 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/.werks/2012 b/.werks/2012
new file mode 100644
index 0000000..7c51d72
--- /dev/null
+++ b/.werks/2012
@@ -0,0 +1,10 @@
+Title: Piggyback hostname translation can now deal correctly with umlauts
+Level: 1
+Component: core
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1424442762
+
+
diff --git a/ChangeLog b/ChangeLog
index 195c66e..79b3e3d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -13,6 +13,7 @@
* 1882 FIX: Fixed exception "filesystem_levels" not defined when compiling
config for nagios
* 1977 FIX: Dramatically reduced size of Check_MK check helper processes...
* 1982 FIX: Fixed exception during checking regular checking when having checks
without discovery function
+ * 2012 FIX: Piggyback hostname translation can now deal correctly with umlauts
Checks & Agents:
* 1665 agent_netapp: New special agent for NetApp monitoring via Web-API...
diff --git a/checks/esx_vsphere_datastores b/checks/esx_vsphere_datastores
index ce2c373..3f2c2b8 100644
--- a/checks/esx_vsphere_datastores
+++ b/checks/esx_vsphere_datastores
@@ -37,6 +37,7 @@
def esx_vsphere_datastores_parse(info):
stores = {}
for line in info:
+ print line
if line[0].startswith('['):
name = line[0][1:-1]
store = {}
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index 7d502a0..33eb289 100644
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -604,6 +604,11 @@ def translate_piggyback_host(sourcehost, backedhost):
if translation.get("drop_domain") and not backedhost[0].isdigit():
backedhost = backedhost.split(".", 1)[0]
+ # To make it possible to match umlauts we need to change the backendhost
+ # to a unicode string which can then be matched with regexes etc.
+ # We assume the incoming name is correctly encoded in UTF-8
+ backedhost = backedhost.decode('utf-8')
+
# 3. Regular expression conversion
if "regex" in translation:
regex, subst = translation.get("regex")
@@ -622,8 +627,7 @@ def translate_piggyback_host(sourcehost, backedhost):
backedhost = to_host
break
- return backedhost
-
+ return backedhost.encode('utf-8') # change back to UTF-8 encoded string
def read_cache_file(relpath, max_cache_age):