Module: check_mk
Branch: master
Commit: 01cab3c1064e43e05d99a46503ad87e5ec3bcffe
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=01cab3c1064e43…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Sep 16 11:34:14 2015 +0200
Perf-O-Meters: Avoid exception in case of useless empty performance variable
---
web/htdocs/metrics.py | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/web/htdocs/metrics.py b/web/htdocs/metrics.py
index 8aeb888..5a1966c 100644
--- a/web/htdocs/metrics.py
+++ b/web/htdocs/metrics.py
@@ -301,13 +301,16 @@ def parse_perf_data(perf_data_string, check_command=None):
value_parts = values.split(";")
while len(value_parts) < 5:
value_parts.append(None)
- value, warn, crit, min, max = value_parts[0:5]
+ value_text, warn, crit, min, max = value_parts[0:5]
+ if value_text == "":
+ continue # ignore useless empty variable
+
# separate value from unit
i = 0
- while i < len(value) and (isdigit(value[i]) or value[i] in ['.',
',', '-']):
+ while i < len(value_text) and (isdigit(value_text[i]) or value_text[i] in
['.', ',', '-']):
i += 1
- unit_name = value[i:]
- value = value[:i]
+ unit_name = value_text[i:]
+ value = value_text[:i]
perf_data.append((varname, value, unit_name, warn, crit, min, max))
except:
if config.debug:
@@ -330,6 +333,7 @@ def translate_metrics(perf_data, check_command):
color_index = 0
for nr, entry in enumerate(perf_data):
varname = entry[0]
+ value_text = entry[1]
translation_entry = {} # Default: no translation neccessary
@@ -362,9 +366,8 @@ def translate_metrics(perf_data, check_command):
# Optional scaling
scale = translation_entry.get("scale", 1.0)
-
new_entry = {
- "value" : float_or_int(entry[1]) * scale,
+ "value" : float_or_int(value_text) * scale,
"orig_name" : varname,
"scale" : scale, # needed for graph definitions
"scalar" : {},