Module: check_mk
Branch: master
Commit: d4fa4a36111013172a773cf830020b51310268b4
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d4fa4a36111013…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Nov 10 15:26:52 2015 +0100
#2758 FIX Fixed processing of metrics containing varnames with quotes and/or spaces
---
.werks/2758 | 10 ++++++++++
ChangeLog | 1 +
web/htdocs/metrics.py | 9 ++++++---
3 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/.werks/2758 b/.werks/2758
new file mode 100644
index 0000000..cb7623b
--- /dev/null
+++ b/.werks/2758
@@ -0,0 +1,10 @@
+Title: Fixed processing of metrics containing varnames with quotes and/or spaces
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i4
+Date: 1447165571
+
+
diff --git a/ChangeLog b/ChangeLog
index 01bde39..515645a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -83,6 +83,7 @@
* 2729 FIX: Hosts/Hostproblems snapin: Fixed wrong livestatus query when filtering
lists
* 2709 FIX: fixed exception when opening the action menu...
* 2447 FIX: Fixed sorting of performancedata values with units...
+ * 2758 FIX: Fixed processing of metrics containing varnames with quotes and/or
spaces
WATO:
* 2442 WATO remove host: improved cleanup of obsolete host files...
diff --git a/web/htdocs/metrics.py b/web/htdocs/metrics.py
index 12b96c1..3bca3e0 100644
--- a/web/htdocs/metrics.py
+++ b/web/htdocs/metrics.py
@@ -34,7 +34,7 @@
# unit: The definition-dict of a unit like in unit_info
# graph_template: Template for a graph. Essentially a dict with the key
"metrics"
-import math, time, colorsys
+import math, time, colorsys, shlex
import config, defaults, pagetypes, table
from lib import *
from valuespec import *
@@ -278,12 +278,14 @@ def mix_colors(a, b):
# 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"
+ # FIXME: check_command=None? Fails here!
check_command = check_command.split("!")[0]
if not perf_data_string:
return None, check_command
- parts = perf_data_string.split()
+ # Split the perf data string into parts. Preserve quoted strings!
+ parts = shlex.split(perf_data_string)
# Try if check command is appended to performance data
# in a PNP like style
@@ -300,7 +302,8 @@ def parse_perf_data(perf_data_string, check_command=None):
try:
perf_data = []
for part in parts:
- varname, values = part.split("=")
+ varname, values = part.split("=", 1)
+ varname = varname.replace("\"",
"").replace("\'", "")
value_parts = values.split(";")
while len(value_parts) < 5:
value_parts.append(None)