Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / docker_node_disk_usage
blob0234bc90529ded235396b631a58ca606d1721115
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 inventory_docker_node_disk_usage(parsed):
29 for item in parsed:
30 yield item, {}
33 def check_docker_node_disk_usage(item, params, parsed):
34 data = parsed.get(item)
35 if data is None:
36 return
38 for key, param, conversion_func in (
39 ('Size', 'size', get_filesize_human_readable),
40 ('Reclaimable', 'reclaimable', get_filesize_human_readable),
41 ('TotalCount', 'count', lambda x: x),
42 ('Active', 'active', lambda x: x),
44 value = data[key]
46 warn, crit = params.get(param, (None, None))
47 if crit is not None and value >= crit:
48 status, lvl_text = 2, " (warn/crit at %s/%s)" % (warn, crit)
49 elif warn is not None and value >= warn:
50 status, lvl_text = 1, " (warn/crit at %s/%s)" % (warn, crit)
51 else:
52 status, lvl_text = 0, ""
54 infotext = "%s: %s%s" % (param, conversion_func(value), lvl_text)
55 perfdata = [(param, value, warn, crit)]
57 yield status, infotext, perfdata
60 check_info["docker_node_disk_usage"] = {
61 "parse_function": parse_legacy_docker_system_df,
62 "inventory_function": inventory_docker_node_disk_usage,
63 "check_function": check_docker_node_disk_usage,
64 "service_description": "Docker disk usage - %s",
65 "includes": ["legacy_docker.include"],
66 "has_perfdata": True,
67 "group": "docker_node_disk_usage",