Cleanup config.nodes_of
[check_mk.git] / checks / docker_node_disk_usage
blobd5355e2af736eeb44c318156ce4e437f9f95fe89
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2018 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.
28 def parse_docker_node_disk_usage(info):
29 version = docker_get_version(info) # pylint: disable=undefined-variable
31 if version is None:
32 return parse_legacy_docker_system_df(info) # pylint: disable=undefined-variable
34 table_rows = map(docker_json_get_obj, info[1:]) # pylint: disable=undefined-variable
35 return {r.get('type'): r for r in table_rows if r is not None}
38 @append_deprecation_warning # pylint: disable=undefined-variable
39 @get_parsed_item_data
40 def check_docker_node_disk_usage(_no_item, params, data):
42 for param, conversion_func in (
43 ('size', get_filesize_human_readable),
44 ('reclaimable', get_filesize_human_readable),
45 ('count', lambda x: x),
46 ('active', lambda x: x),
48 value = data[param]
50 warn, crit = params.get(param, (None, None))
51 if crit is not None and value >= crit:
52 status, lvl_text = 2, " (warn/crit at %s/%s)" % (warn, crit)
53 elif warn is not None and value >= warn:
54 status, lvl_text = 1, " (warn/crit at %s/%s)" % (warn, crit)
55 else:
56 status, lvl_text = 0, ""
58 infotext = "%s: %s%s" % (param, conversion_func(value), lvl_text)
59 perfdata = [(param, value, warn, crit)]
61 yield status, infotext, perfdata
64 check_info["docker_node_disk_usage"] = {
65 "parse_function": parse_docker_node_disk_usage,
66 "inventory_function": discover(),
67 "check_function": check_docker_node_disk_usage,
68 "service_description": "Docker disk usage - %s",
69 "includes": ['docker.include', 'legacy_docker.include'],
70 "has_perfdata": True,
71 "group": "docker_node_disk_usage",