[checkmk-commits] Check_MK Git: check_mk: Fixed exception in several Perf-O-Meters

Mathias Kettner mk at mathias-kettner.de
Wed Feb 4 13:39:07 CET 2015


Module: check_mk
Branch: master
Commit: 7e3121b7773133869c2a1203546c5282b31b6819
URL:    http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7e3121b7773133869c2a1203546c5282b31b6819

Author: Mathias Kettner <mk at mathias-kettner.de>
Date:   Wed Feb  4 13:39:04 2015 +0100

Fixed exception in several Perf-O-Meters

---

 web/htdocs/metrics.py           |   10 +++++-----
 web/plugins/metrics/check_mk.py |    2 +-
 web/plugins/views/perfometer.py |    3 ++-
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/web/htdocs/metrics.py b/web/htdocs/metrics.py
index 28c3a44..3941cce 100644
--- a/web/htdocs/metrics.py
+++ b/web/htdocs/metrics.py
@@ -25,8 +25,8 @@
 # Boston, MA 02110-1301 USA.
 
 # Frequently used variable names an terms
-# perf_data_string: Raw performance data as sent by the core, e.g "foor=17M;1;2;4;5"
-# perf_data:        Split performance data, e.g. [("foo", "17", "M", "1", "2", "4", "5")]
+# perf_data_string:   Raw performance data as sent by the core, e.g "foor=17M;1;2;4;5"
+# perf_data:          Split performance data, e.g. [("foo", "17", "M", "1", "2", "4", "5")]
 # translated_metrics: Completely parsed and translated into metrics, e.g. { "foo" : { "value" : 17.0, "unit" : { "render" : ... }, ... } }
 
 
@@ -160,10 +160,10 @@ def translate_metrics(check_command, perf_data):
 # e.g. "fs_used(%)"     -> 17.5
 # e.g. "fs_used:max(%)" -> 100.0
 def evaluate(expression, translated_metrics):
-    if ',' in expression:
-        return evaluate_rpn(expression, translated_metrics)
-    else:
+    if type(expression) in (float, int) or "," not in expression:
         return evaluate_literal(expression, translated_metrics)
+    else:
+        return evaluate_rpn(expression, translated_metrics)
 
 rpn_operators = {
     "+" : lambda a, b: (a + b),
diff --git a/web/plugins/metrics/check_mk.py b/web/plugins/metrics/check_mk.py
index 24e1fa0..cd86fbd 100644
--- a/web/plugins/metrics/check_mk.py
+++ b/web/plugins/metrics/check_mk.py
@@ -311,7 +311,7 @@ check_metrics["check_mk-lparstat_aix.cpu_util"]                 = { "wait" : { "
 #   |  Definition of Perf-O-Meters                                         |
 #   '----------------------------------------------------------------------'
 
-perfometer_info.append(("stacked",      ( ["execution_time"], 90.0)))
+perfometer_info.append(("stacked",      ( ["execution_time"], 90.0, None)))
 perfometer_info.append(("logarithmic",  ( "load1",         4.0, 2.0)))
 perfometer_info.append(("logarithmic",  ( "temp",         40.0, 1.2)))
 perfometer_info.append(("logarithmic",  ( "ctxt",       1000.0, 2.0)))
diff --git a/web/plugins/views/perfometer.py b/web/plugins/views/perfometer.py
index e364d86..50c9cbf 100644
--- a/web/plugins/views/perfometer.py
+++ b/web/plugins/views/perfometer.py
@@ -150,7 +150,8 @@ def paint_perfometer(row):
 
             title, h = perf_painter(row, check_command, perf_data)
             # Test code for optically detecting old-style Perf-O-Meters
-            title = '{ ' + title + ' }'
+            if config.debug:
+                title = '{ ' + title + ' }'
 
     except Exception, e:
         if config.debug:



More information about the checkmk-commits mailing list