Module: check_mk
Branch: master
Commit: 049db5a26167ec92c0a3a06519c1a206cbd493d7
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=049db5a26167ec…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Thu Apr 4 15:24:33 2019 +0200
mongodb_collections: simplify
Change-Id: I7c9d507d25d4f4bdc8d394f336922893ccff5c1c
---
checks/mongodb_collections | 19 +++++--------------
1 file changed, 5 insertions(+), 14 deletions(-)
diff --git a/checks/mongodb_collections b/checks/mongodb_collections
index 2c9d1ec..bd681a8 100644
--- a/checks/mongodb_collections
+++ b/checks/mongodb_collections
@@ -39,23 +39,14 @@
def parse_mongodb_collections(info):
- databases = {}
- for line in info:
- db, coll, what, value = line
- databases.setdefault(db, {}).setdefault(coll, {})[what] = value
-
parsed = {}
- for db, collections in databases.items():
- for collection, values in collections.items():
- parsed["%s %s" % (db, collection)] = values
+ for line in info:
+ db_name, collection, key, value = line
+ data = parsed.setdefault("%s %s" % (db_name, collection), {})
+ data[key] = value
return parsed
-def inventory_mongodb_collections(parsed):
- for item in parsed:
- yield item, {}
-
-
def check_mongodb_collections(item, params, parsed):
fslist_blocks = []
for coll_item, values in parsed.items():
@@ -68,8 +59,8 @@ def check_mongodb_collections(item, params, parsed):
check_info["mongodb_collections"] = {
"parse_function": parse_mongodb_collections,
+ "inventory_function": discover(),
"check_function": check_mongodb_collections,
- "inventory_function": inventory_mongodb_collections,
"service_description": "MongoDB Collection %s",
"group": "mongodb_collections",
"default_levels_variable": "filesystem_default_levels",