Module: check_mk
Branch: master
Commit: 25c1c43bbbf78113008d6f658a4fdc6f25456568
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=25c1c43bbbf781…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Jun 30 15:37:46 2015 +0200
Fixed computation of service descriptions when having unicode strings
---
modules/check_mk.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 270b032..4399fe6 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -1265,13 +1265,14 @@ def service_description(check_type, item):
# can by empty in some cases. Nagios silently drops leading
# and trailing spaces in the configuration file.
- if type(item) == str:
+ item_type = type(item)
+ if item_type in [ str, unicode ]:
# Remove characters from item name that are banned by Nagios
item_safe = sanitize_service_description(item)
if "%s" not in descr_format:
descr_format += " %s"
return (descr_format % (item_safe,)).strip()
- if type(item) == int or type(item) == long:
+ elif item_type in [ int, long ]:
if "%s" not in descr_format:
descr_format += " %s"
return (descr_format % (item,)).strip()