Cleanup config.nodes_of
[check_mk.git] / checks / dell_poweredge.include
blobdb1454b2ef177477ccb4e555a8e6d5b53358e2cb
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2018 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 # .--CPU-----------------------------------------------------------------.
28 # | ____ ____ _ _ |
29 # | / ___| _ \| | | | |
30 # | | | | |_) | | | | |
31 # | | |___| __/| |_| | |
32 # | \____|_| \___/ |
33 # | |
34 # '----------------------------------------------------------------------'
37 def inventory_dell_poweredge_cpu(info):
38 for _chassisIndex, _Index, StateSettings, _Status, LocationName in info[0]:
39 if LocationName != "" and StateSettings != "1":
40 yield LocationName, None
43 def check_dell_poweredge_cpu(item, _no_params, info):
44 for chassisIndex, Index, _StateSettings, Status, LocationName in info[0]:
45 if item == LocationName:
46 BrandName = None
47 for line in info[1]:
48 if line[0] == chassisIndex and line[1] == Index:
49 BrandName = line[2]
51 state_table = {
52 "1": ("other", 1),
53 "2": ("unknown", 1),
54 "3": ("", 0),
55 "4": ("non-critical", 1),
56 "5": ("critical", 2),
57 "6": ("non-recoverable", 2),
60 infotext, state = state_table.get(Status, ("unknown state", 2))
61 if BrandName:
62 infotext += " " + BrandName
64 return state, infotext
68 # .--memory--------------------------------------------------------------.
69 # | |
70 # | _ __ ___ ___ _ __ ___ ___ _ __ _ _ |
71 # | | '_ ` _ \ / _ \ '_ ` _ \ / _ \| '__| | | | |
72 # | | | | | | | __/ | | | | | (_) | | | |_| | |
73 # | |_| |_| |_|\___|_| |_| |_|\___/|_| \__, | |
74 # | |___/ |
75 # '----------------------------------------------------------------------'
78 def inventory_dell_poweredge_mem(info):
79 inventory = []
80 for line in info:
81 location = line[1]
82 if location != "":
83 inventory.append((location, None))
84 return inventory
87 def check_dell_poweredge_mem(item, _no_params, info):
88 di = dict()
89 for status, location, size, di['Speed'], di['MFR'], di['P/N'], di['S/N'] in info:
91 di['Size'] = str(saveint(size) / 1024 / 1024) + "GB"
92 if item == location:
93 state_table = {
94 "1": ("other", 1),
95 "2": ("unknown", 1),
96 "3": ("", 0),
97 "4": ("nonCritical", 1),
98 "5": ("Critical", 2),
99 "6": ("NonRecoverable", 2),
101 infotext, state = state_table.get(status, ("unknown state", 2))
102 for parameter, value in di.items():
103 infotext += ", %s: %s" % (parameter, value)
105 infotext = re.sub("^, ", "", infotext)
107 return state, infotext
109 return 3, "Memory Device not found"
113 # .--netdev--------------------------------------------------------------.
114 # | _ _ |
115 # | _ __ ___| |_ __| | _____ __ |
116 # | | '_ \ / _ \ __/ _` |/ _ \ \ / / |
117 # | | | | | __/ || (_| | __/\ V / |
118 # | |_| |_|\___|\__\__,_|\___| \_/ |
119 # | |
120 # '----------------------------------------------------------------------'
123 def inventory_dell_poweredge_netdev(info):
124 inventory = []
125 for line in info:
126 if line[1] != "2" and line[4] != "":
127 inventory.append((line[4], None))
128 return inventory
131 def check_dell_poweredge_netdev(item, _no_params, info):
132 di = dict()
133 for status, connection_status, di['Product'], cur_mac, fqdd in info:
134 if item == fqdd:
135 di['MAC'] = '-'.join(["%02X" % ord(c) for c in cur_mac]).strip()
136 state_table = {
137 "1": ("other,", 1),
138 "2": ("unknown,", 1),
139 "3": ("", 0),
140 "4": ("nonCritical,", 1),
141 "5": ("Critical,", 2),
142 "6": ("NonRecoverable,", 2),
144 connection_table = {
145 "1": ("connected, ", 0),
146 "2": ("disconnected, ", 2),
147 "3": ("driverBad, ", 2),
148 "4": ("driverDisabled, ", 2),
149 "10": ("hardwareInitializing, ", 2),
150 "11": ("hardwareResetting, ", 2),
151 "12": ("hardwareClosing, ", 2),
152 "13": ("hardwareNotReady, ", 2),
154 dev_state_txt, dev_state = state_table.get(status, ("unknown device status,", 2))
155 conn_state_txt, conn_state = connection_table.get(connection_status, ("", 0))
156 state = max(dev_state, conn_state)
157 infotext = "%s %s" % (dev_state_txt, conn_state_txt)
158 for parameter, value in di.items():
159 infotext += "%s: %s, " % (parameter, value)
160 infotext = re.sub(", $", "", infotext)
162 return state, infotext
164 return 3, "network device not found"
168 # .--PCI-----------------------------------------------------------------.
169 # | ____ ____ ___ |
170 # | | _ \ / ___|_ _| |
171 # | | |_) | | | | |
172 # | | __/| |___ | | |
173 # | |_| \____|___| |
174 # | |
175 # '----------------------------------------------------------------------'
178 def inventory_dell_poweredge_pci(info):
179 inventory = []
180 for line in info:
181 fqdd = line[4]
182 if fqdd != "":
183 inventory.append((fqdd, None))
184 return inventory
187 def check_dell_poweredge_pci(item, _no_params, info):
188 di = dict()
189 for status, di['BusWidth'], di['MFR'], di['Desc.'], fqdd in info:
191 if item == fqdd:
192 state_table = {
193 "1": ("other", 1),
194 "2": ("unknown", 1),
195 "3": ("", 0),
196 "4": ("nonCritical", 1),
197 "5": ("Critical", 2),
198 "6": ("NonRecoverable", 2),
200 infotext, state = state_table.get(status, ("unknown state", 2))
201 for parameter, value in di.items():
202 infotext += ", %s: %s" % (parameter, value)
204 infotext = re.sub("^, ", "", infotext)
206 return state, infotext
208 return 3, "Memory Device not found"
212 # .--status--------------------------------------------------------------.
213 # | _ _ |
214 # | ___| |_ __ _| |_ _ _ ___ |
215 # | / __| __/ _` | __| | | / __| |
216 # | \__ \ || (_| | |_| |_| \__ \ |
217 # | |___/\__\__,_|\__|\__,_|___/ |
218 # | |
219 # '----------------------------------------------------------------------'
222 def inventory_dell_poweredge_status(info):
223 if info:
224 return [(None, None)]
227 def check_dell_poweredge_status(item, _no_params, info):
228 di = dict()
229 di['racURL'], di['Chassis'], di['Slot'], di['Model'], status, di['ServiceTag'], di[
230 'ExpressServiceCode'] = info[0]
232 state_table = {
233 "1": ("other, ", 1),
234 "2": ("unknown, ", 1),
235 "3": ("", 0),
236 "4": ("nonCritical, ", 1),
237 "5": ("Critical, ", 2),
238 "6": ("NonRecoverable, ", 2),
240 infotext, state = state_table.get(status, "2")
241 for parameter, value in di.items():
242 infotext += "%s: %s, " % (parameter, value)
243 infotext = re.sub(", $", "", infotext)
245 return state, infotext
249 # .--power---------------------------------------------------------------.
250 # | |
251 # | _ __ _____ _____ _ __ |
252 # | | '_ \ / _ \ \ /\ / / _ \ '__| |
253 # | | |_) | (_) \ V V / __/ | |
254 # | | .__/ \___/ \_/\_/ \___|_| |
255 # | |_| |
256 # '----------------------------------------------------------------------'
259 def inventory_dell_poweredge_amperage_power(info):
260 inventory = []
261 for line in info:
262 if line[6] != "" and line[5] in ("24", "26"):
263 inventory.append((line[6], None))
264 return inventory
267 def check_dell_poweredge_amperage(item, _no_params, info):
268 for _chassisIndex, _Index, _StateSettings, Status, Reading, ProbeType, LocationName, \
269 UpperCritical, UpperNonCritical in info:
271 if item == LocationName:
272 state_table = {
273 "1": ("other", 1),
274 "2": ("unknown", 1),
275 "3": ("", 0),
276 "4": ("nonCriticalUpper", 1),
277 "5": ("CriticalUpper", 2),
278 "6": ("NonRecoverableUpper", 2),
279 "7": ("nonCriticalLower", 1),
280 "8": ("CriticalLower", 2),
281 "9": ("NonRecoverableLower", 2),
282 "10": ("failed", 2),
284 state_txt, state = state_table.get(Status, "2")
286 if UpperNonCritical and UpperCritical:
287 limittext = " (upper limits %s/%s)" % (UpperNonCritical, UpperCritical)
288 maxi = savefloat(UpperCritical) * 1.1
289 else:
290 limittext = ""
291 maxi = ""
293 if ProbeType in ("23", "25"): # Amps
294 current = str(int(Reading) / 10.0)
295 infotext = "%s Ampere %s" % (current, state_txt)
296 perfdata = [("current", current + "A", UpperNonCritical, UpperCritical, "", maxi)]
297 elif ProbeType in ("24", "26"): # Watts
298 infotext = "%s Watt %s" % (Reading, state_txt)
299 perfdata = [("power", Reading + "W", UpperNonCritical, UpperCritical, "", maxi)]
300 else:
301 infotext = "Unknown Probe Type %s" % ProbeType
302 return 3, infotext
304 return state, infotext + limittext, perfdata
306 return 3, "Amperage Device not found"
310 # .--temperature---------------------------------------------------------.
311 # | _ _ |
312 # | | |_ ___ _ __ ___ _ __ ___ _ __ __ _| |_ _ _ _ __ ___ |
313 # | | __/ _ \ '_ ` _ \| '_ \ / _ \ '__/ _` | __| | | | '__/ _ \ |
314 # | | || __/ | | | | | |_) | __/ | | (_| | |_| |_| | | | __/ |
315 # | \__\___|_| |_| |_| .__/ \___|_| \__,_|\__|\__,_|_| \___| |
316 # | |_| |
317 # '----------------------------------------------------------------------'
320 def dell_poweredge_temp_makeitem(chassisIndex, Index, LocationName):
321 if LocationName:
322 item = LocationName
323 else:
324 item = chassisIndex + "-" + Index
325 if item.endswith(" Temp"):
326 item = item[:-5]
327 return item
330 def inventory_dell_poweredge_temp(info):
331 for line in info:
332 if line[2] != '1': # StateSettings not 'unknown'
333 item = dell_poweredge_temp_makeitem(line[0], line[1], line[5])
334 yield item, {}
337 def check_dell_poweredge_temp(item, params, info):
338 for chassisIndex, Index, _StateSettings, Status, Reading, LocationName, \
339 UpperCritical, UpperNonCritical, LowerNonCritical, LowerCritical in info:
340 if item == dell_poweredge_temp_makeitem(chassisIndex, Index, LocationName):
341 temp = int(Reading) / 10.0
343 if UpperNonCritical and UpperCritical:
344 levels = (int(UpperNonCritical) / 10.0, int(UpperCritical) / 10.0)
345 else:
346 levels = None, None
347 if LowerNonCritical and LowerCritical:
348 lower_levels = int(LowerNonCritical) / 10.0, int(LowerCritical) / 10.0
349 else:
350 lower_levels = None, None
352 state_table = {
353 "1": ("other", 1),
354 "2": ("unknown", 1),
355 "3": ("", 0),
356 "4": ("nonCriticalUpper", 1),
357 "5": ("CriticalUpper", 2),
358 "6": ("NonRecoverableUpper", 2),
359 "7": ("nonCriticalLower", 1),
360 "8": ("CriticalLower", 2),
361 "9": ("NonRecoverableLower", 2),
362 "10": ("failed", 2),
364 state_txt, state = state_table.get(Status, ("unknown state", 3))
365 if state:
366 yield state, state_txt
367 yield check_temperature(
368 temp,
369 params,
370 "dell_poweredge_temp_%s" % item,
371 dev_levels=levels,
372 dev_levels_lower=lower_levels)