Module: check_mk
Branch: master
Commit: 2119b1c933bd95f097539b846eb2cc519bda266f
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2119b1c933bd95…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Thu Apr 4 15:50:46 2019 +0200
mongodb_collections: some refactoring
Change-Id: I914de6e0f2b450d5e1f99e60cf3d6a3dda7c0a98
---
checks/mongodb_collections | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/checks/mongodb_collections b/checks/mongodb_collections
index bd681a8..5c5208c 100644
--- a/checks/mongodb_collections
+++ b/checks/mongodb_collections
@@ -39,19 +39,24 @@
def parse_mongodb_collections(info):
+ required_keys_int = ("size", "storageSize")
parsed = {}
for line in info:
db_name, collection, key, value = line
data = parsed.setdefault("%s %s" % (db_name, collection), {})
- data[key] = value
+ if key in required_keys_int:
+ try:
+ data[key] = int(value)
+ except ValueError:
+ pass
return parsed
def check_mongodb_collections(item, params, parsed):
fslist_blocks = []
for coll_item, values in parsed.items():
- used_mb = float(values["size"]) / 1024.0**2
- total_mb = float(values["storageSize"]) / 1024.0**2
+ used_mb = values["size"] / 1024.0**2
+ total_mb = values["storageSize"] / 1024.0**2
fslist_blocks.append((coll_item, total_mb, total_mb - used_mb, 0))
return df_check_filesystem_list(item, params, fslist_blocks)