Module: check_mk
Branch: master
Commit: e5946d15e3c21022c0499c83938fc92fd5ebb2c9
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e5946d15e3c210…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Nov 10 15:37:49 2015 +0100
Made perfdata split work with python<2.5
---
web/htdocs/metrics.py | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/web/htdocs/metrics.py b/web/htdocs/metrics.py
index 3bca3e0..98b2a84 100644
--- a/web/htdocs/metrics.py
+++ b/web/htdocs/metrics.py
@@ -275,6 +275,13 @@ def mix_colors(a, b):
# | Parsing of performance data into metrics, evaluation of expressions |
# '----------------------------------------------------------------------'
+
+def split_perf_data(perf_data_string):
+ # In python < 2.5 shlex.split can not deal with unicode strings. But we always
+ # have unicode strings. So encode and decode again.
+ return map(lambda s: s.decode('utf-8'),
shlex.split(perf_data_string.encode('utf-8')))
+
+
# Convert perf_data_string into perf_data, extract check_command
def parse_perf_data(perf_data_string, check_command=None):
# Strip away arguments like in "check_http!-H mathias-kettner.de"
@@ -285,7 +292,7 @@ def parse_perf_data(perf_data_string, check_command=None):
return None, check_command
# Split the perf data string into parts. Preserve quoted strings!
- parts = shlex.split(perf_data_string)
+ parts = split_perf_data(perf_data_string)
# Try if check command is appended to performance data
# in a PNP like style