Module: check_mk
Branch: master
Commit: 1218e3c48444619d9e99603819cfff74bb793bf0
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1218e3c4844461…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Jul 25 12:21:44 2016 +0200
3622 FIX Fix labelling of V-Achsis on graphs with very large numbers
If you create an own check that outputs very large metrics then the
labelling of the vertical axis in a graph would try to display numbers
like 1000000000000, with the problem that the prefix 1000... is not
visible.
Number larger than 99999 are now being displayed in exponential
syntax, e.g. 1.0e6 and are thus correctly being displayed.
---
.werks/3622 | 17 +++++++++++++++++
ChangeLog | 1 +
web/htdocs/lib.py | 9 +++++++++
web/plugins/metrics/check_mk.py | 2 +-
4 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/.werks/3622 b/.werks/3622
new file mode 100644
index 0000000..7411638
--- /dev/null
+++ b/.werks/3622
@@ -0,0 +1,17 @@
+Title: Fix labelling of V-Achsis on graphs with very large numbers
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.4.0i1
+Date: 1469441963
+
+If you create an own check that outputs very large metrics then the
+labelling of the vertical axis in a graph would try to display numbers
+like 1000000000000, with the problem that the prefix 1000... is not
+visible.
+
+Number larger than 99999 are now being displayed in exponential
+syntax, e.g. 1.0e6 and are thus correctly being displayed.
+
diff --git a/ChangeLog b/ChangeLog
index fabe220..9284fb8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -403,6 +403,7 @@
* 3668 FIX: Fixed slow loading of GUI pages when using a localized GUI
* 3669 FIX: LDAP: Fixed very long running LDAP sync when using group based sync
plugins
* 3670 FIX: Fixed empty AV PDF report when exporting it from a quicksearch result
view
+ * 3622 FIX: Fix labelling of V-Achsis on graphs with very large numbers...
WATO:
* 3244 WATO BI Module: swap order of aggregation function and child node
selection...
diff --git a/web/htdocs/lib.py b/web/htdocs/lib.py
index a737416..79c77f4 100644
--- a/web/htdocs/lib.py
+++ b/web/htdocs/lib.py
@@ -484,6 +484,13 @@ def frexp10(x):
return frexpb(x, 10)
+def render_scientific(v, precision=3):
+ mantissa, exponent = frexp10(float(v))
+ # Render small numbers without exponent
+ if exponent >= -3 and exponent <= 4:
+ return "%%.%df" % max(0, precision - exponent) % v
+
+ return "%%.%dfe%%d" % precision % (mantissa, exponent)
# Render a physical value witha precision of p
@@ -624,6 +631,8 @@ def render_float_with_precision(value, precision):
return "%%.%df" % digits % value
+
+
def number_human_readable(n, precision=1, unit="B"):
base = 1024.0
if unit == "Bit":
diff --git a/web/plugins/metrics/check_mk.py b/web/plugins/metrics/check_mk.py
index 4eec359..27a6ab4 100644
--- a/web/plugins/metrics/check_mk.py
+++ b/web/plugins/metrics/check_mk.py
@@ -65,7 +65,7 @@ unit_info[""] = {
"title" : "",
"description" : _("Floating point number"),
"symbol" : "",
- "render" : lambda v: render_float_with_precision(v, 3),
+ "render" : lambda v: render_scientific(v, 2),
}
unit_info["count"] = {