Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / mongodb_collections
blob2c9d1ecaf725e7fb3f72fe0100ee75ec0db8ab05
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
11 # +------------------------------------------------------------------+
13 # This file is part of Check_MK.
14 # The official homepage is at http://mathias-kettner.de/check_mk.
16 # check_mk is free software; you can redistribute it and/or modify it
17 # under the terms of the GNU General Public License as published by
18 # the Free Software Foundation in version 2. check_mk is distributed
19 # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
20 # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
21 # PARTICULAR PURPOSE. See the GNU General Public License for more de-
22 # tails. You should have received a copy of the GNU General Public
23 # License along with GNU Make; see the file COPYING. If not, write
24 # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
25 # Boston, MA 02110-1301 USA.
27 # <<<mongodb_collections:sep(9)>>>
28 # tanserver tans count 0
29 # tanserver tans indexDetails {}
30 # tanserver tans storageSize 8192
31 # tanserver tans ok 1.0
32 # tanserver tans lastExtentSize 8192.0
33 # tanserver tans userFlags 1
34 # tanserver tans totalIndexSize 24528
35 # tanserver tans capped False
36 # tanserver tans numExtents 1
37 # tanserver tans nindexes 3
38 # tanserver tans ns tanserver.tans
41 def parse_mongodb_collections(info):
42 databases = {}
43 for line in info:
44 db, coll, what, value = line
45 databases.setdefault(db, {}).setdefault(coll, {})[what] = value
47 parsed = {}
48 for db, collections in databases.items():
49 for collection, values in collections.items():
50 parsed["%s %s" % (db, collection)] = values
51 return parsed
54 def inventory_mongodb_collections(parsed):
55 for item in parsed:
56 yield item, {}
59 def check_mongodb_collections(item, params, parsed):
60 fslist_blocks = []
61 for coll_item, values in parsed.items():
62 used_mb = float(values["size"]) / 1024.0**2
63 total_mb = float(values["storageSize"]) / 1024.0**2
64 fslist_blocks.append((coll_item, total_mb, total_mb - used_mb, 0))
66 return df_check_filesystem_list(item, params, fslist_blocks)
69 check_info["mongodb_collections"] = {
70 "parse_function": parse_mongodb_collections,
71 "check_function": check_mongodb_collections,
72 "inventory_function": inventory_mongodb_collections,
73 "service_description": "MongoDB Collection %s",
74 "group": "mongodb_collections",
75 "default_levels_variable": "filesystem_default_levels",
76 "includes": ["size_trend.include", "df.include"],
77 "has_perfdata": True,