Module: check_mk
Branch: master
Commit: 263836ecbdacd0bc8f0c20b6c4148e0d9a6e66ec
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=263836ecbdacd0…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Apr 9 14:34:47 2015 +0200
Fix exception in CPU load graph, if number of cores is None
---
web/htdocs/metrics.py | 5 ++++-
web/plugins/metrics/check_mk.py | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/web/htdocs/metrics.py b/web/htdocs/metrics.py
index 29ac803..cc1e831 100644
--- a/web/htdocs/metrics.py
+++ b/web/htdocs/metrics.py
@@ -388,7 +388,10 @@ def replace_expressions(text, translated_metrics):
value, unit, color = evaluate(expression, translated_metrics)
if unit_name:
unit = unit_info[unit_name]
- return unit["render"](value)
+ if value != None:
+ return unit["render"](value)
+ else:
+ return _("n/a")
r = regex(r"%\([^)]*\)")
return r.sub(eval_to_string, text)
diff --git a/web/plugins/metrics/check_mk.py b/web/plugins/metrics/check_mk.py
index 06205d7..6e2c984 100644
--- a/web/plugins/metrics/check_mk.py
+++ b/web/plugins/metrics/check_mk.py
@@ -48,7 +48,7 @@ unit_info[""] = {
unit_info["count"] = {
"title" : _("Count"),
"symbol" : "",
- "render" : lambda v : "%d" % v,
+ "render" : lambda v: "%d" % v,
"stepping" : "integer", # for vertical graph labels
}