Module: check_mk
Branch: master
Commit: 33ccf81c4bfee98b018bc5a53b215976cd9e31cc
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=33ccf81c4bfee9…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Fri Mar 8 15:39:59 2013 +0100
perfometer: Bit values now using base of 1000
---
ChangeLog | 1 +
web/plugins/views/perfometer.py | 16 ++++++++++------
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 92fe1ad..b64a43c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -14,6 +14,7 @@
* Added plugins to config module to make registration of default values
possible for addons like mkeventd - reset to default values works now
correctly even for multisite related settings
+ * perfometer: Bit values now using base of 1000
* ADD: check_disk_smb pnp-template
Event Console:
diff --git a/web/plugins/views/perfometer.py b/web/plugins/views/perfometer.py
index 8553c3f..a334f05 100644
--- a/web/plugins/views/perfometer.py
+++ b/web/plugins/views/perfometer.py
@@ -91,14 +91,18 @@ def perfometer_logarithmic_dual(value_left, color_left, value_right,
color_right
def number_human_readable(n, precision=1, unit="B"):
+ base = 1024.0
+ if unit == "Bit":
+ base = 1000.0
+
n = float(n)
f = "%." + str(precision) + "f"
- if abs(n) > 1024 * 1024 * 1024:
- return (f + "G%s") % (n / (1024.0 * 1024 * 1024), unit)
- elif abs(n) > 1024 * 1024:
- return (f + "M%s") % (n / (1024.0 * 1024), unit)
- elif abs(n) > 1024:
- return (f + "k%s") % (n / 1024.0, unit)
+ if abs(n) > base * base * base:
+ return (f + "G%s") % (n / (base * base * base), unit)
+ elif abs(n) > base * base:
+ return (f + "M%s") % (n / (base * base), unit)
+ elif abs(n) > base:
+ return (f + "k%s") % (n / base, unit)
else:
return (f + "%s") % (n, unit)