2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2013 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 # <<<ucs_bladecenter_psu:sep(9)>>>
28 # equipmentPsuInputStats Dn sys/switch-A/psu-2/input-stats Current 0.656250 PowerAvg 153.335938 Voltage 231.500000
29 # equipmentPsuStats Dn sys/chassis-1/psu-1/stats AmbientTemp 17.000000 Output12vAvg 12.008000 Output3v3Avg 3.336000
32 def ucs_bladecenter_psu_parse(info
):
33 data
= ucs_bladecenter_convert_info(info
)
36 def get_item_name(key
):
37 tokens
= key
.split("/")
38 tokens
[1] = tokens
[1].replace("psu-", " Module ")
39 tokens
= [x
[0].upper() + x
[1:] for x
in tokens
]
40 return "".join(tokens
).replace("-", " ")
42 for component
, key_low
, key_high
in [
43 ("equipmentPsuInputStats", 4, -12),
44 ("equipmentPsuStats", 4, -6),
46 for key
, values
in data
.get(component
, {}).items():
47 name
= get_item_name(key
[key_low
:key_high
])
49 psu
.setdefault(name
, {}).update(values
)
55 # .--Chassis Volt.-------------------------------------------------------.
56 # | ____ _ _ __ __ _ _ |
57 # | / ___| |__ __ _ ___ ___(_)___ \ \ / /__ | | |_ |
58 # | | | | '_ \ / _` / __/ __| / __| \ \ / / _ \| | __| |
59 # | | |___| | | | (_| \__ \__ \ \__ \ \ V / (_) | | |_ _ |
60 # | \____|_| |_|\__,_|___/___/_|___/ \_/ \___/|_|\__(_) |
62 # '----------------------------------------------------------------------'
64 factory_settings
["ucs_bladecenter_psu_default_levels"] = {
65 "levels_3v_lower": (3.25, 3.20),
66 "levels_3v_upper": (3.4, 3.45),
67 "levels_12v_lower": (11.9, 11.8),
68 "levels_12v_upper": (12.1, 12.2)
72 def inventory_ucs_bladecenter_psu(parsed
):
73 for key
in parsed
.keys():
74 if key
.startswith("Chassis"):
79 def check_ucs_bladecenter_psu(item
, params
, psu
):
80 for param_key
, perfname
, key
, text
in [("levels_3v_", "3_3v", "Output3v3Avg",
81 "Output 3.3V-Average"),
82 ("levels_12v_", "12v", "Output12vAvg",
83 "Output 12V-Average")]:
84 voltage
= float(psu
[key
])
85 yield 0, "%s: %.2f V" % (text
, voltage
), [(perfname
, voltage
)]
87 warn_lower
, crit_lower
= params
[param_key
+ "lower"]
88 if voltage
<= crit_lower
:
89 yield 2, "too low (warn/crit below %.2f/%.2f V)" % params
[param_key
+ "lower"]
90 elif voltage
<= warn_lower
:
91 yield 1, "too low (warn/crit below %.2f/%.2f V)" % params
[param_key
+ "lower"]
93 warn_upper
, crit_upper
= params
[param_key
+ "upper"]
94 if voltage
>= crit_upper
:
95 yield 2, "too high (warn/crit at %.2f/%.2f V)" % params
[param_key
+ "upper"]
96 elif voltage
>= warn_upper
:
97 yield 1, "too high (warn/crit at %.2f/%.2f V)" % params
[param_key
+ "upper"]
100 check_info
["ucs_bladecenter_psu"] = {
101 'parse_function': ucs_bladecenter_psu_parse
,
102 'inventory_function': inventory_ucs_bladecenter_psu
,
103 'check_function': check_ucs_bladecenter_psu
,
104 'service_description': 'Voltage %s',
105 'group': 'ucs_bladecenter_chassis_voltage',
106 'includes': ['ucs_bladecenter.include'],
107 'has_perfdata': True,
108 'default_levels_variable': "ucs_bladecenter_psu_default_levels",
112 # .--Power Supply--------------------------------------------------------.
114 # | | _ \ _____ _____ _ __ / ___| _ _ _ __ _ __ | |_ _ |
115 # | | |_) / _ \ \ /\ / / _ \ '__| \___ \| | | | '_ \| '_ \| | | | | |
116 # | | __/ (_) \ V V / __/ | ___) | |_| | |_) | |_) | | |_| | |
117 # | |_| \___/ \_/\_/ \___|_| |____/ \__,_| .__/| .__/|_|\__, | |
119 # '----------------------------------------------------------------------'
122 def inventory_ucs_bladecenter_psu_switch_power(parsed
):
123 for key
in parsed
.iterkeys():
124 if key
.startswith("Switch"):
128 @get_parsed_item_data
129 def check_ucs_bladecenter_psu_switch_power(item
, params
, psu
):
131 KEY_MAP
= {"Current": "current", "PowerAvg": "power", "Voltage": "voltage"}
134 for k
, v
in psu
.iteritems():
136 k
, v
= KEY_MAP
[k
], (float(v
), None)
139 return check_elphase(item
, params
, {item
: psu_new
})
142 check_info
["ucs_bladecenter_psu.switch_power"] = {
143 'inventory_function': inventory_ucs_bladecenter_psu_switch_power
,
144 'check_function': check_ucs_bladecenter_psu_switch_power
,
145 'service_description': 'Power Supply %s',
146 'includes': ['ucs_bladecenter.include', 'elphase.include'],
147 'has_perfdata': True,
148 'group': "el_inphase"
152 # .--Temperature---------------------------------------------------------.
154 # | |_ _|__ _ __ ___ _ __ ___ _ __ __ _| |_ _ _ _ __ ___ |
155 # | | |/ _ \ '_ ` _ \| '_ \ / _ \ '__/ _` | __| | | | '__/ _ \ |
156 # | | | __/ | | | | | |_) | __/ | | (_| | |_| |_| | | | __/ |
157 # | |_|\___|_| |_| |_| .__/ \___|_| \__,_|\__|\__,_|_| \___| |
159 # '----------------------------------------------------------------------'
161 factory_settings
["ucs_bladecenter_psu_chassis_temp_default_levels"] = {
166 def inventory_ucs_bladecenter_psu_chassis_temp(parsed
):
167 for key
, values
in parsed
.items():
168 if key
.startswith("Chassis") and values
.get("AmbientTemp"):
169 yield "Ambient " + " ".join(key
.split()[:2]), {}
172 def check_ucs_bladecenter_psu_chassis_temp(item
, params
, parsed
):
173 sensor_item
= item
[8:] # drop "Ambient "
176 for key
, values
in sorted(parsed
.items()):
177 if key
.startswith(sensor_item
) and "AmbientTemp" in values
:
179 "Module %s" % key
.split()[-1],
180 float(values
.get("AmbientTemp")),
182 return check_temperature_list(sensor_list
, params
, "ucs_bladecenter_psu_chassis_temp_%s" % item
)
185 check_info
["ucs_bladecenter_psu.chassis_temp"] = {
186 'inventory_function': inventory_ucs_bladecenter_psu_chassis_temp
,
187 'check_function': check_ucs_bladecenter_psu_chassis_temp
,
188 'service_description': 'Temperature %s',
189 'group': 'temperature',
190 'has_perfdata': True,
191 'default_levels_variable': "ucs_bladecenter_psu_chassis_temp_default_levels",
192 'includes': ['ucs_bladecenter.include', 'temperature.include'],