Cleanup config.nodes_of
[check_mk.git] / checks / ibm_svc_mdisk
blobbd8878ec94678ce7daef572e017910853db3b59c
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2014 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 # Example output from agent:
28 # <<<ibm_svc_mdisk:sep(58)>>>
29 # 0:stp5_300G_01-01:online:managed:16:stp5_300G_01:1.1TB:0000000000000000:BLUBB5:600a0b80006e1dbc0000f6f9513026a000000000000000000000000000000000:generic_hdd
30 # 1:Quorum_BLUBB3:online:managed:0:Quorum_2:1.0GB:0000000000000000:BLUBB3:600a0b8000293eb800001f264c3e8a1f00000000000000000000000000000000:generic_hdd
31 # 2:stp6_300G_01-01:online:managed:15:stp6_300G_01:1.1TB:0000000000000000:BLUBB6:600a0b80006e8e3c00000f1651302b8800000000000000000000000000000000:generic_hdd
32 # 3:Quorum_blubb5:online:managed:18:Quorum_0:1.0GB:0000000000000001:BLUBB5:600a0b80006e1dcc0000f6905130225800000000000000000000000000000000:generic_hdd
33 # 4:Quorum_blubb6:online:managed:17:Quorum_1:1.0GB:0000000000000001:BLUBB6:600a0b80006e1d5e00000dcb5130228700000000000000000000000000000000:generic_hdd
34 # 5:stp5_300G_01-02:online:managed:16:stp5_300G_01:1.1TB:0000000000000002:BLUBB5:600a0b80006e1dbc0000f6fc51304bfc00000000000000000000000000000000:generic_hdd
35 # 6:stp6_300G_01-02:online:managed:15:stp6_300G_01:1.1TB:0000000000000002:BLUBB6:600a0b80006e8e3c00000f1951304f9a00000000000000000000000000000000:generic_hdd
36 # 7:stp5_300G_01-03:online:managed:16:stp5_300G_01:1.1TB:0000000000000003:BLUBB5:600a0b80006e1dcc0000f76951305bc000000000000000000000000000000000:generic_hdd
37 # 8:stp6_300G_01-03:online:managed:15:stp6_300G_01:1.1TB:0000000000000003:BLUBB6:600a0b80006e1d5e00000e9a51305a3200000000000000000000000000000000:generic_hdd
38 # 9:stp5_300G_01-04:online:managed:16:stp5_300G_01:1.1TB:0000000000000004:BLUBB5:600a0b80006e1dbc0000f7d051341cc000000000000000000000000000000000:generic_hdd
40 factory_settings['ibm_svc_mdisk_default_levels'] = {
41 'online_state': 0, # online state is OK
42 'degraded_state': 1, # degraded state is WARN
43 'offline_state': 2, # offline state is CRIT
44 'excluded_state': 2, # excluded state is CRIT
45 'managed_mode': 0, # managed mode is OK
46 'array_mode': 0, # array mode is OK
47 'image_mode': 0, # image mode is OK
48 'unmanaged_mode': 1, # unmanaged mode is WARN
52 def parse_ibm_svc_mdisk(info):
53 dflt_header = [
54 u'id',
55 u'name',
56 u'status',
57 u'mode',
58 u'mdisk_grp_id',
59 u'mdisk_grp_name',
60 u'capacity',
61 u'ctrl_LUN_#',
62 u'controller_name',
63 u'UID',
64 u'tier',
65 u'encrypt',
66 u'site_id',
67 u'site_name',
68 u'distributed',
69 u'dedupe',
71 parsed = {}
72 for rows in parse_ibm_svc_with_header(info, dflt_header).itervalues():
73 try:
74 data = rows[0]
75 except IndexError:
76 continue
77 parsed.setdefault(data['name'], data)
78 return parsed
81 def inventory_ibm_svc_mdisk(parsed):
82 for mdisk_name in parsed.iterkeys():
83 yield mdisk_name, {}
86 @get_parsed_item_data
87 def check_ibm_svc_mdisk(item, params, data):
88 mdisk_status = data['status']
89 yield params.get("%s_state" % mdisk_status, 1), "Status: %s" % mdisk_status
91 mdisk_mode = data['mode']
92 yield params.get("%s_mode" % mdisk_mode, 1), "Mode: %s" % mdisk_mode
95 check_info["ibm_svc_mdisk"] = {
96 "parse_function": parse_ibm_svc_mdisk,
97 "check_function": check_ibm_svc_mdisk,
98 "inventory_function": inventory_ibm_svc_mdisk,
99 "service_description": "MDisk %s",
100 "includes": ['ibm_svc.include'],
101 "group": "ibm_svc_mdisk",
102 "default_levels_variable": "ibm_svc_mdisk_default_levels",