2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
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-----------------------------------------------------------------.
29 # | / ___| _ \| | | | |
30 # | | | | |_) | | | | |
31 # | | |___| __/| |_| | |
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
:
48 if line
[0] == chassisIndex
and line
[1] == Index
:
55 "4": ("non-critical", 1),
57 "6": ("non-recoverable", 2),
60 infotext
, state
= state_table
.get(Status
, ("unknown state", 2))
62 infotext
+= " " + BrandName
64 return state
, infotext
68 # .--memory--------------------------------------------------------------.
70 # | _ __ ___ ___ _ __ ___ ___ _ __ _ _ |
71 # | | '_ ` _ \ / _ \ '_ ` _ \ / _ \| '__| | | | |
72 # | | | | | | | __/ | | | | | (_) | | | |_| | |
73 # | |_| |_| |_|\___|_| |_| |_|\___/|_| \__, | |
75 # '----------------------------------------------------------------------'
78 def inventory_dell_poweredge_mem(info
):
83 inventory
.append((location
, None))
87 def check_dell_poweredge_mem(item
, _no_params
, info
):
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"
97 "4": ("nonCritical", 1),
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--------------------------------------------------------------.
115 # | _ __ ___| |_ __| | _____ __ |
116 # | | '_ \ / _ \ __/ _` |/ _ \ \ / / |
117 # | | | | | __/ || (_| | __/\ V / |
118 # | |_| |_|\___|\__\__,_|\___| \_/ |
120 # '----------------------------------------------------------------------'
123 def inventory_dell_poweredge_netdev(info
):
126 if line
[1] != "2" and line
[4] != "":
127 inventory
.append((line
[4], None))
131 def check_dell_poweredge_netdev(item
, _no_params
, info
):
133 for status
, connection_status
, di
['Product'], cur_mac
, fqdd
in info
:
135 di
['MAC'] = '-'.join(["%02X" % ord(c
) for c
in cur_mac
]).strip()
138 "2": ("unknown,", 1),
140 "4": ("nonCritical,", 1),
141 "5": ("Critical,", 2),
142 "6": ("NonRecoverable,", 2),
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-----------------------------------------------------------------.
170 # | | _ \ / ___|_ _| |
172 # | | __/| |___ | | |
175 # '----------------------------------------------------------------------'
178 def inventory_dell_poweredge_pci(info
):
183 inventory
.append((fqdd
, None))
187 def check_dell_poweredge_pci(item
, _no_params
, info
):
189 for status
, di
['BusWidth'], di
['MFR'], di
['Desc.'], fqdd
in info
:
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--------------------------------------------------------------.
214 # | ___| |_ __ _| |_ _ _ ___ |
215 # | / __| __/ _` | __| | | / __| |
216 # | \__ \ || (_| | |_| |_| \__ \ |
217 # | |___/\__\__,_|\__|\__,_|___/ |
219 # '----------------------------------------------------------------------'
222 def inventory_dell_poweredge_status(info
):
224 return [(None, None)]
227 def check_dell_poweredge_status(item
, _no_params
, info
):
229 di
['racURL'], di
['Chassis'], di
['Slot'], di
['Model'], status
, di
['ServiceTag'], di
[
230 'ExpressServiceCode'] = info
[0]
234 "2": ("unknown, ", 1),
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---------------------------------------------------------------.
251 # | _ __ _____ _____ _ __ |
252 # | | '_ \ / _ \ \ /\ / / _ \ '__| |
253 # | | |_) | (_) \ V V / __/ | |
254 # | | .__/ \___/ \_/\_/ \___|_| |
256 # '----------------------------------------------------------------------'
259 def inventory_dell_poweredge_amperage_power(info
):
262 if line
[6] != "" and line
[5] in ("24", "26"):
263 inventory
.append((line
[6], None))
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
:
276 "4": ("nonCriticalUpper", 1),
277 "5": ("CriticalUpper", 2),
278 "6": ("NonRecoverableUpper", 2),
279 "7": ("nonCriticalLower", 1),
280 "8": ("CriticalLower", 2),
281 "9": ("NonRecoverableLower", 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
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
)]
301 infotext
= "Unknown Probe Type %s" % ProbeType
304 return state
, infotext
+ limittext
, perfdata
306 return 3, "Amperage Device not found"
310 # .--temperature---------------------------------------------------------.
312 # | | |_ ___ _ __ ___ _ __ ___ _ __ __ _| |_ _ _ _ __ ___ |
313 # | | __/ _ \ '_ ` _ \| '_ \ / _ \ '__/ _` | __| | | | '__/ _ \ |
314 # | | || __/ | | | | | |_) | __/ | | (_| | |_| |_| | | | __/ |
315 # | \__\___|_| |_| |_| .__/ \___|_| \__,_|\__|\__,_|_| \___| |
317 # '----------------------------------------------------------------------'
320 def dell_poweredge_temp_makeitem(chassisIndex
, Index
, LocationName
):
324 item
= chassisIndex
+ "-" + Index
325 if item
.endswith(" Temp"):
330 def inventory_dell_poweredge_temp(info
):
332 if line
[2] != '1': # StateSettings not 'unknown'
333 item
= dell_poweredge_temp_makeitem(line
[0], line
[1], line
[5])
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)
347 if LowerNonCritical
and LowerCritical
:
348 lower_levels
= int(LowerNonCritical
) / 10.0, int(LowerCritical
) / 10.0
350 lower_levels
= None, None
356 "4": ("nonCriticalUpper", 1),
357 "5": ("CriticalUpper", 2),
358 "6": ("NonRecoverableUpper", 2),
359 "7": ("nonCriticalLower", 1),
360 "8": ("CriticalLower", 2),
361 "9": ("NonRecoverableLower", 2),
364 state_txt
, state
= state_table
.get(Status
, ("unknown state", 3))
366 yield state
, state_txt
367 yield check_temperature(
370 "dell_poweredge_temp_%s" % item
,
372 dev_levels_lower
=lower_levels
)