GUI CSS: Deployed view styles for layouts (CMK-1171)
[check_mk.git] / checks / ucs_bladecenter_fans
blob72402a544dfa06b40056d9ce6d76ccf835438ede
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
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_fans:sep(9)>>>
28 # equipmentNetworkElementFanStats Dn sys/switch-A/fan-module-1-1/fan-1/stats SpeedAvg 8542
29 # equipmentFanModuleStats Dn sys/chassis-2/fan-module-1-1/stats AmbientTemp 29.000000
30 # equipmentFan Dn sys/chassis-1/fan-module-1-1/fan-1 Model N20-FAN5 OperState operable
31 # equipmentFanStats Dn sys/chassis-2/fan-module-1-1/fan-1/stats SpeedAvg 3652
34 def parse_ucs_bladecenter_fans(info):
35 data = ucs_bladecenter_convert_info(info)
36 fans = {}
38 def get_item_name(key):
39 tokens = key.split("/")
40 tokens[1] = tokens[1].replace("fan-module-", "Module ").replace("-", ".")
41 tokens = [x[0].upper() + x[1:] for x in tokens]
42 if len(tokens) > 2:
43 tokens[2] = tokens[2].replace("fan-", ".")
44 return " ".join(tokens).replace("-", " ")
46 for component, key_low, key_high in [
47 ("equipmentNetworkElementFanStats", 4, -6),
48 ("equipmentFanModuleStats", 4, -6),
49 ("equipmentFan", 4, 100),
50 ("equipmentFanStats", 4, -6),
52 for key, values in data.get(component, {}).items():
53 fan = key[key_low:key_high]
54 del values["Dn"]
55 name = get_item_name(fan)
56 fans.setdefault(name, {}).update(values)
58 return fans
61 # .--Fans----------------------------------------------------------------.
62 # | _____ |
63 # | | ___|_ _ _ __ ___ |
64 # | | |_ / _` | '_ \/ __| |
65 # | | _| (_| | | | \__ \ |
66 # | |_| \__,_|_| |_|___/ |
67 # | |
68 # '----------------------------------------------------------------------'
71 def inventory_ucs_bladecenter_fans(parsed):
72 for key, values in parsed.items():
73 if "SpeedAvg" in values:
74 yield " ".join(key.split()[:2]), None
77 def check_ucs_bladecenter_fans(item, _no_params, parsed):
78 my_fans = {}
79 for key, values in parsed.items():
80 if key.startswith(item) and "OperState" in values:
81 my_fans[key] = values
83 if not my_fans:
84 yield 3, "Fan statistics not available"
85 return
87 yield 0, "%d Fans" % len(my_fans)
88 for key, fan in sorted(my_fans.items()):
89 if fan["OperState"] != "operable":
90 yield 2, "Fan %s %s: average speed %s RPM" % \
91 (key.split()[-1][2:], fan["OperState"], fan.get("SpeedAvg"))
94 check_info["ucs_bladecenter_fans"] = {
95 'parse_function': parse_ucs_bladecenter_fans,
96 'inventory_function': inventory_ucs_bladecenter_fans,
97 'check_function': check_ucs_bladecenter_fans,
98 'service_description': 'Fans %s',
99 'includes': ['ucs_bladecenter.include'],
103 # .--Temperature---------------------------------------------------------.
104 # | _____ _ |
105 # | |_ _|__ _ __ ___ _ __ ___ _ __ __ _| |_ _ _ _ __ ___ |
106 # | | |/ _ \ '_ ` _ \| '_ \ / _ \ '__/ _` | __| | | | '__/ _ \ |
107 # | | | __/ | | | | | |_) | __/ | | (_| | |_| |_| | | | __/ |
108 # | |_|\___|_| |_| |_| .__/ \___|_| \__,_|\__|\__,_|_| \___| |
109 # | |_| |
110 # '----------------------------------------------------------------------'
112 factory_settings["ucs_bladecenter_fans_temp_default_levels"] = {
113 "levels": (40, 50),
117 # Fans are grouped per module, usually 8 components
118 def inventory_ucs_bladecenter_fans_temp(parsed):
119 for key, values in parsed.items():
120 if "AmbientTemp" in values:
121 yield "Ambient %s FAN" % " ".join(key.split()[:2]), {}
124 def check_ucs_bladecenter_fans_temp(item, params, parsed):
125 sensor_item = item[8:-4] # drop "Ambient " and " FAN"
126 sensor_list = []
127 for key, values in parsed.items():
128 if key.startswith(sensor_item) and "AmbientTemp" in values:
129 loc = key.split()[-1].split(".")
130 sensor_list.append((
131 "Module %s Fan %s" % (loc[0], loc[1]),
132 float(values.get("AmbientTemp")),
134 return check_temperature_list(sensor_list, params, "ucs_bladecenter_fans_%s" % item)
137 check_info["ucs_bladecenter_fans.temp"] = {
138 'inventory_function': inventory_ucs_bladecenter_fans_temp,
139 'check_function': check_ucs_bladecenter_fans_temp,
140 'service_description': 'Temperature %s',
141 'group': 'temperature',
142 'has_perfdata': True,
143 'includes': ['ucs_bladecenter.include', 'temperature.include'],
144 'default_levels_variable': 'ucs_bladecenter_fans_temp_default_levels'