Module: check_mk
Branch: master
Commit: cc9e591e458208cd309e41b7badb124a963072fc
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=cc9e591e458208…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Apr 26 14:11:09 2011 +0200
FIX: avoid floating points with e in performance data
---
ChangeLog | 1 +
modules/check_mk_base.py | 10 +++++++---
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b765fdd..3e7aed8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
1.1.11i1:
Core, Setup, etc.:
+ * FIX: avoid floating points with 'e' in performance data
* FIX: cmk -D: drop obsolete (and always empty) Notification:
* FIX: better handling of broken checks returning empty services
* FIX: fix computation of weight when averaging
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index 31c0aba..9c1e601 100755
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -888,11 +888,15 @@ def open_command_pipe():
-def none_to_empty(x):
+def convert_perf_value(x):
if x == None:
return ""
- else:
+ elif type(x) in [ str, unicode ]:
return x
+ elif type(x) == float:
+ return ("%.6f" % x).rstrip("0").rstrip(".")
+ else:
+ return str(x)
def submit_check_result(host, servicedesc, result, sa):
@@ -921,7 +925,7 @@ def submit_check_result(host, servicedesc, result, sa):
for p in perfdata:
# replace None with "" and fill up to 6 values
- p = (map(none_to_empty, p) +
['','','',''])[0:6]
+ p = (map(convert_perf_value, p) +
['','','',''])[0:6]
perftexts.append("%s=%s;%s;%s;%s;%s" % tuple(p) )
if perftexts != [] and not direct_rrd_update(host, servicedesc, perfdata):
if check_command and perfdata_format == "pnp":