Module: check_mk
Branch: master
Commit: 51b987cd0697445a7e77fb245a337f6d38d0a9dc
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=51b987cd069744…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Feb 24 10:59:48 2017 +0100
4399 FIX Views: Fixed graph showing views of services with invalid perfdata
Some checks that produced invalid perfdata like 'key=" "' were causing
the
metric parsing to crash with a "IndexError (list index out of range)" error.
The metric parsing is now skipping those invalid values.
Change-Id: I5b0ab12e2a0d32546823c8a588fdadd6c9453d0b
---
.werks/4399 | 14 ++++++++++++++
web/htdocs/metrics.py | 4 +++-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/.werks/4399 b/.werks/4399
new file mode 100644
index 0000000..d0be212
--- /dev/null
+++ b/.werks/4399
@@ -0,0 +1,14 @@
+Title: Views: Fixed graph showing views of services with invalid perfdata
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i1
+Date: 1487930278
+
+Some checks that produced invalid perfdata like 'key=" "' were causing
the
+metric parsing to crash with a "IndexError (list index out of range)" error.
+
+The metric parsing is now skipping those invalid values.
diff --git a/web/htdocs/metrics.py b/web/htdocs/metrics.py
index 7240e48..be5bc61 100644
--- a/web/htdocs/metrics.py
+++ b/web/htdocs/metrics.py
@@ -351,7 +351,7 @@ def parse_perf_data(perf_data_string, check_command=None):
while len(value_parts) < 5:
value_parts.append(None)
value_text, warn, crit, min, max = value_parts[0:5]
- if value_text == "":
+ if value_text.strip() == "":
continue # ignore useless empty variable
# separate value from unit
@@ -361,6 +361,8 @@ def parse_perf_data(perf_data_string, check_command=None):
i += 1
unit_name = value_text[i:]
+ if value_text[:i] == "":
+ continue
value = float_or_int(value_text[:i])
perf_data_tuple = (varname, value, unit_name)