2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
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_enclosure:sep(58)>>>
29 # 1:online:control:yes:0:io_grp0:2072-24C:7804037:2:2:2:2:24
30 # 2:online:expansion:yes:0:io_grp0:2072-24E:7804306:2:2:2:2:24
31 # 3:online:expansion:yes:0:io_grp0:2072-24E:7804326:2:2:2:2:24
32 # 4:online:expansion:yes:0:io_grp0:2072-24E:7804352:2:2:2:2:24
34 # After a firmware upgrade the output looked like this:
35 # 1:online:control:yes:0:io_grp0:2072-24C:7804037:2:2:2:2:24:0:0
36 # 2:online:expansion:yes:0:io_grp0:2072-24E:7804306:2:2:2:2:24:0:0
37 # 3:online:expansion:yes:0:io_grp0:2072-24E:7804326:2:2:2:2:24:0:0
38 # 4:online:expansion:yes:0:io_grp0:2072-24E:7804352:2:2:2:2:24:0:0
41 # 1:online:control:yes:0:io_grp0:2072-24C:7804037:2:2:2:2:24:0:0:0:0
42 # 2:online:expansion:yes:0:io_grp0:2072-24E:7804306:2:2:2:2:24:0:0:0:0
43 # 3:online:expansion:yes:0:io_grp0:2072-24E:7804326:2:2:2:2:24:0:0:0:0
44 # 4:online:expansion:yes:0:io_grp0:2072-24E:7804352:2:2:2:2:24:0:0:0:0
46 # The names of the columns are:
47 # id:status:type:managed:IO_group_id:IO_group_name:product_MTM:serial_number:total_canisters:online_canisters:total_PSUs:online_PSUs:drive_slots:total_fan_modules:online_fan_modules:total_sems:online_sems
50 # <<<ibm_svc_enclosure:sep(58)>>>
51 # id:status:type:product_MTM:serial_number:total_canisters:online_canisters:online_PSUs:drive_slots
52 # 1:online:control:9843-AE2:6860407:2:2:2:12
55 def parse_ibm_svc_enclosure(info
):
56 dflt_header
= _get_ibm_svc_enclosure_dflt_header(info
)
57 if dflt_header
is None:
61 for id_
, rows
in parse_ibm_svc_with_header(info
, dflt_header
).iteritems():
66 parsed
.setdefault(id_
, data
)
73 except (ValueError, TypeError):
78 def check_ibm_svc_enclosure(item
, params
, data
):
79 enclosure_status
= data
['status']
80 if enclosure_status
== "online":
84 yield status
, 'Status: %s' % enclosure_status
87 ('canisters', 'canisters'),
89 ('fan_modules', 'fan modules'),
90 ('sems', 'secondary expander modules'),
92 online
= _try_int(data
.get("online_%s" % key
))
93 total
= _try_int(data
.get("total_%s" % key
))
96 # Valid values for WATO rule value levels_lower_online_canisters are
97 # False, which shall be mapped to (total, total) or (warn, crit).
98 levels_lower
= params
.get("levels_lower_online_%s" % key
) or (total
, total
)
99 levels
= (None, None) + levels_lower
100 state
, infotext
, _perfdata
= check_levels(
101 online
, None, levels
, human_readable_func
=int, infoname
="Online %s" % label
)
102 if total
is not None:
103 infotext
+= " of %s" % total
104 yield state
, infotext
107 check_info
["ibm_svc_enclosure"] = {
108 "parse_function": parse_ibm_svc_enclosure
,
109 "check_function": check_ibm_svc_enclosure
,
110 "inventory_function": discover(),
111 "service_description": "Enclosure %s",
112 "includes": ["ibm_svc.include"],
113 "group": "ibm_svc_enclosure",
116 # .--helper--------------------------------------------------------------.
118 # | | |__ ___| |_ __ ___ _ __ |
119 # | | '_ \ / _ \ | '_ \ / _ \ '__| |
120 # | | | | | __/ | |_) | __/ | |
121 # | |_| |_|\___|_| .__/ \___|_| |
123 # '----------------------------------------------------------------------'
126 def _get_ibm_svc_enclosure_dflt_header(info
):
132 if len(first_line
) == 9:
144 elif len(first_line
) == 13:
160 elif len(first_line
) == 15:
176 'online_fan_modules',
178 elif len(first_line
) == 17:
194 'online_fan_modules',