Cleanup config.nodes_of
[check_mk.git] / checks / 3par_capacity
blob424c4685651094a78a4fe567212a0f91c6018e21
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2017 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_3par_capacity(parsed):
29 for key, value in parsed.iteritems():
30 if value['totalMiB'] == 0:
31 continue
32 yield (key.replace("Capacity", ""), {})
35 def check_3par_capacity(item, params, parsed):
36 for key, value in parsed.iteritems():
37 if key.replace("Capacity", "") == item:
38 total = value['totalMiB']
39 free = value['freeMiB']
40 failed = value['failedCapacityMiB']
42 yield df_check_filesystem_list(item, params, [(item, total, free, failed)])
44 if failed == 0:
45 return
47 failed_percent = float(failed) / float(total) * 100.0
48 warn, crit = params.get("failed_capacity_levels", (0.0, 0.0))
49 msg = "%s MB / %.1f%% failed (warn/crit at %.1f%%/%.1f%%)" \
50 % (failed, failed_percent, warn, crit)
51 if failed_percent >= crit:
52 yield 2, msg
53 elif failed_percent >= warn:
54 yield 1, msg
57 check_info['3par_capacity'] = {
58 'parse_function': parse_3par,
59 'inventory_function': inventory_3par_capacity,
60 'check_function': check_3par_capacity,
61 'service_description': "Capacity %s",
62 'has_perfdata': True,
63 'includes': ["3par.include", "size_trend.include", "df.include"],
64 'group': "threepar_capacity",
65 'default_levels_variable': "filesystem_default_levels",