2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2019 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 # exemplary output of special agent agent_ucs_bladecenter (<TAB> is tabulator):
29 # <<<ucs_c_rack_server_psu:sep(9)>>>
30 # equipmentPsu<TAB>dn sys/rack-unit-1/psu-1<TAB>id 1<TAB>model blabla<TAB>operability operable<TAB>voltage upper-critical
31 # equipmentPsu<TAB>dn sys/rack-unit-1/psu-2 <TAB>id 2<TAB>model blabla<TAB>operability inoperable<TAB>voltage ok
34 def parse_ucs_c_rack_server_psu(info
):
36 Returns dict with indexed PSUs mapped to keys and operability, voltage values mapped to dicts.
41 key_value_pairs
= [kv
.split(" ", 1) for kv
in psu
[1:]]
42 psu
= key_value_pairs
[0][1].replace("sys/", "").replace("rack-unit-",
43 "Rack Unit ").replace(
46 'operability': key_value_pairs
[3][1],
47 'voltage': key_value_pairs
[4][1],
50 continue # skip info line in case agent output is incomplete or invalid
54 def inventory_ucs_c_rack_server_psu(parsed
):
56 Yields indexed PSUs as items (e.g. Rack Unit 1 PSU 1).
58 for key
in parsed
.keys():
62 #########################
63 # ucs_c_rack_server_psu #
64 #########################
68 def check_ucs_c_rack_server_psu(item
, _no_params
, data
):
69 # maps XML API v2.0 XML entity values to check function status values
70 operability_to_status_mapping
= {
80 "performance-problem": 2,
81 "accessibility-problem": 2,
82 "identity-unestablishable": 1,
83 "bios-post-timeout": 1,
86 "fabric-conn-problem": 2,
87 "fabric-unsupported-conn": 1,
89 "equipment-problem": 2,
91 "chassis-limit-exceeded": 1,
94 "discovery-failed": 1,
98 "peer-comm-problem": 2,
101 operability
= data
["operability"]
103 status
= operability_to_status_mapping
[operability
]
104 status_readable
= operability
107 status_readable
= "unknown[%s]" % operability
108 yield status
, "Status: %s" % status_readable
111 check_info
["ucs_c_rack_server_psu"] = {
112 'parse_function': parse_ucs_c_rack_server_psu
,
113 'inventory_function': inventory_ucs_c_rack_server_psu
,
114 'check_function': check_ucs_c_rack_server_psu
,
115 'service_description': 'Output Power %s',
118 #################################
119 # ucs_c_rack_server_psu.voltage #
120 #################################
123 @get_parsed_item_data
124 def check_ucs_c_rack_server_psu_voltage(item
, _no_params
, data
):
125 # maps XML API v2.0 XML entity values to check function status values
126 voltage_to_status_mapping
= {
129 "upper-non-recoverable": 2,
131 "upper-non-critical": 1,
132 "lower-non-critical": 1,
134 "lower-non-recoverable": 2,
137 voltage_status
= data
["voltage"]
139 status
= voltage_to_status_mapping
[voltage_status
]
140 status_readable
= voltage_status
143 status_readable
= "unknown[%s]" % voltage_status
144 yield status
, "Status: %s" % status_readable
147 check_info
["ucs_c_rack_server_psu.voltage"] = {
148 'inventory_function': inventory_ucs_c_rack_server_psu
,
149 'check_function': check_ucs_c_rack_server_psu_voltage
,
150 'service_description': 'Output Voltage %s',