Module: check_mk
Branch: master
Commit: ba12fb5d63f19fbe64af8208e285e573e616c63c
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ba12fb5d63f19f…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Mon Dec 17 07:47:41 2018 +0100
azure.include: add bytes per second formatter
CMK-1409
Change-Id: I6c1fa86a05ac4f37b82074ec99769a8ba53039f2
---
checks/azure.include | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/checks/azure.include b/checks/azure.include
index 52e074c..f610508 100644
--- a/checks/azure.include
+++ b/checks/azure.include
@@ -25,6 +25,14 @@
# Boston, MA 02110-1301 USA.
import json
+_AZURE_METRIC_FMT = {
+ "percent": get_percent_human_readable,
+ "bytes": get_bytes_human_readable,
+ "bytes_per_second": lambda b: "%s/s" %
get_bytes_human_readable(b),
+ "seconds": lambda s: "%.2f s" % s,
+ "milli_seconds": lambda ms: "%d ms" % (ms * 1000),
+}
+
def azure_iter_informative_attrs(resource, include_keys=('location',)):
def cap(string): # not quite what str.title() does
@@ -74,12 +82,7 @@ def check_azure_metric(
value *= 100.
unit = "percent"
- formatter = {
- "percent": get_percent_human_readable,
- "bytes": get_bytes_human_readable,
- "seconds": lambda s: "%.2f s" % s,
- "milli_seconds": lambda ms: "%d ms" % (ms * 1000),
- }.get(unit, str)
+ formatter = _AZURE_METRIC_FMT.get(unit, str)
text = "%s: %s" % (display_name, formatter(value))
l_state, u_state = 0, 0