Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / 3par_cpgs
blob49ad191f08202112fdff276a09b1fe44e9dc4bfd
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 count_3par_vvs(line):
29 return line['numFPVVs'] + line['numTDVVs'] + line['numTPVVs']
32 def inventory_3par_cpgs(parsed):
33 for entry in parsed.get('members', {}):
34 if "name" in entry and count_3par_vvs(entry) > 0:
35 yield (entry['name'], {})
38 def check_3par_cpgs(item, params, parsed):
39 states = {
40 1: (0, "Normal"),
41 2: (1, "Degraded"),
42 3: (2, "Failed"),
45 for entry in parsed.get('members', {}):
46 if entry.get('name') == item:
47 state, state_readable = states[entry['state']]
48 yield state, "%s, %s VVs" % (state_readable, count_3par_vvs(entry))
51 check_info['3par_cpgs'] = {
52 'parse_function': parse_3par,
53 'inventory_function': inventory_3par_cpgs,
54 'check_function': check_3par_cpgs,
55 'service_description': "CPG %s",
56 'includes': ["3par.include", "size_trend.include", "df.include"]
60 def inventory_3par_cpgs_usage(parsed):
61 for entry in parsed.get('members', {}):
62 if count_3par_vvs(entry) > 0:
63 for fs in ["SAUsage", "SDUsage", "UsrUsage"]:
64 yield ("%s %s" % (entry['name'], fs), {})
67 def check_3par_cpgs_usage(item, params, parsed):
68 for entry in parsed.get('members', {}):
69 for fs in ["SAUsage", "SDUsage", "UsrUsage"]:
70 if "%s %s" % (entry.get('name'), fs) == item:
71 total = entry[fs]['totalMiB']
72 free = entry[fs]['totalMiB'] - entry[fs]['usedMiB']
73 yield df_check_filesystem_list(item, params, [(item, total, free, 0)])
76 check_info['3par_cpgs.usage'] = {
77 'inventory_function': inventory_3par_cpgs_usage,
78 'check_function': check_3par_cpgs_usage,
79 'service_description': "CPG %s",
80 'has_perfdata': True,
81 'group': "threepar_cpgs",
82 'default_levels_variable': "filesystem_default_levels",