Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / prism_containers
blob2d9de018092e490e5af7a5cb3955b1c075c7411a
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2016 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 # <<<prism_containers:sep(9)>>>
28 # name usage capacity
29 # DS01_NFS_Nutanix_B2B_Intern_SAS_Contrainer 2518694292480 38575532134515
31 factory_settings['prism_container_default_levels'] = {
32 'levels': (80.0, 90.0), # in percent, defaults based on df checks
36 def inventory_prism_container(parsed):
37 for row in parsed:
38 yield row['name'], {}
41 def check_prism_container(item, params, parsed):
42 for row in parsed:
43 if row['name'] == item:
44 usage, capacity = map(int, (row['usage'], row['capacity']))
46 warn, crit = params['levels']
47 if isinstance(warn, float):
48 warn, crit = [x * capacity for x in (warn, crit)]
50 if usage >= crit:
51 status = 2
52 elif usage >= warn:
53 status = 1
54 else:
55 status = 0
57 if status != 0:
58 warntxt = " (warn/crit at %s/%s)" %\
59 (get_bytes_human_readable(warn), get_bytes_human_readable(crit))
60 else:
61 warntxt = ""
63 return status, "%s of %s used%s" %\
64 (get_bytes_human_readable(usage),
65 get_bytes_human_readable(capacity),
66 warntxt), [('fs_used', usage, warn, crit, 0, capacity)]
69 check_info['prism_containers'] = {
70 'check_function': check_prism_container,
71 'inventory_function': inventory_prism_container,
72 'parse_function': parse_prism,
73 'group': "prism_container",
74 'has_perfdata': True,
75 'service_description': "Container %s",
76 'includes': ["prism.include"],
77 'default_levels_variable': 'prism_container_default_levels'