2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2014 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 # ails. 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 hp_proliant_status_map
= {
35 hp_proliant_status2nagios_map
= {
44 hp_proliant_locale
= {
60 # .--da cntlr------------------------------------------------------------.
62 # | __| | __ _ ___ _ __ | |_| |_ __ |
63 # | / _` |/ _` | / __| '_ \| __| | '__| |
64 # | | (_| | (_| | | (__| | | | |_| | | |
65 # | \__,_|\__,_| \___|_| |_|\__|_|_| |
67 # '----------------------------------------------------------------------'
69 hp_proliant_da_cntlr_cond_map
= {
76 hp_proliant_da_cntlr_role_map
= {
83 hp_proliant_da_cntlr_state_map
= {
86 '3': (2, 'generalFailure'),
87 '4': (2, 'cableProblem'),
88 '5': (2, 'poweredOff'),
92 def inventory_hp_proliant_da_cntlr(info
):
94 return [(line
[0], None) for line
in info
]
97 def check_hp_proliant_da_cntlr(item
, params
, info
):
99 index
, model
, slot
, cond
, role
, b_status
, b_cond
, serial
= line
104 for val
, label
, map_
in [(cond
, 'Condition', hp_proliant_da_cntlr_cond_map
),
105 (b_cond
, 'Board-Condition', hp_proliant_da_cntlr_cond_map
),
106 (b_status
, 'Board-Status', hp_proliant_da_cntlr_state_map
)]:
107 this_state
= map_
[val
][0]
111 elif this_state
== 2:
113 sum_state
= max(sum_state
, this_state
)
114 output
.append('%s: %s%s' % (label
, map_
[val
][1], state_txt
))
116 output
.append('(Role: %s, Model: %s, Slot: %s, Serial: %s)' %
117 (hp_proliant_da_cntlr_role_map
.get(role
, 'unknown'), model
, slot
, serial
))
119 return (sum_state
, ', '.join(output
))
120 return (3, "Controller not found in snmp data")
124 # .--cpu-----------------------------------------------------------------.
127 # | / __| '_ \| | | | |
128 # | | (__| |_) | |_| | |
129 # | \___| .__/ \__,_| |
131 # '----------------------------------------------------------------------'
133 hp_proliant_cpu_status_map
= {1: "unknown", 2: "ok", 3: "degraded", 4: "failed", 5: "disabled"}
134 hp_proliant_cpu_status2nagios_map
= {
143 def inventory_hp_proliant_cpu(info
):
145 return [(line
[0], None) for line
in info
]
148 def check_hp_proliant_cpu(item
, params
, info
):
151 index
, slot
, name
, status
= line
152 snmp_status
= hp_proliant_cpu_status_map
[int(status
)]
153 status
= hp_proliant_cpu_status2nagios_map
[snmp_status
]
156 'CPU%s "%s" in slot %s is in state "%s"' % (index
, name
, slot
, snmp_status
))
157 return (3, "item not found in snmp data")
161 # .--fans----------------------------------------------------------------.
163 # | / _| __ _ _ __ ___ |
164 # | | |_ / _` | '_ \/ __| |
165 # | | _| (_| | | | \__ \ |
166 # | |_| \__,_|_| |_|___/ |
168 # '----------------------------------------------------------------------'
170 hp_proliant_fans_status_map
= {1: 'other', 2: 'ok', 3: 'degraded', 4: 'failed'}
171 hp_proliant_status2nagios_map
= {'other': 3, 'ok': 0, 'degraded': 2, 'failed': 2}
172 hp_proliant_present_map
= {1: 'other', 2: 'absent', 3: 'present'}
173 hp_proliant_speed_map
= {1: 'other', 2: 'normal', 3: 'high'}
174 hp_proliant_fans_locale
= {
191 def inventory_hp_proliant_fans(info
):
194 for line
in [line
for line
in info
if line
[2] == '3']:
196 if int(line
[1]) in hp_proliant_fans_locale
:
197 label
= hp_proliant_fans_locale
[int(line
[1])]
198 items
.append(("%s (%s)" % (line
[0], label
), None))
202 def check_hp_proliant_fans(item
, params
, info
):
205 if len(line
) > 1 and int(line
[1]) in hp_proliant_fans_locale
:
206 label
= hp_proliant_fans_locale
[int(line
[1])]
208 if "%s (%s)" % (line
[0], label
) == item
:
209 index
, _name
, _present
, speed
, status
, currentSpeed
= line
210 snmp_status
= hp_proliant_fans_status_map
[int(status
)]
211 status
= hp_proliant_status2nagios_map
[snmp_status
]
215 if currentSpeed
!= '':
216 detailOutput
= ', RPM: %s' % currentSpeed
217 perfdata
= [('temp', int(currentSpeed
))]
219 return (status
, 'FAN Sensor %s "%s", Speed is %s, State is %s%s' %
220 (index
, label
, hp_proliant_speed_map
[int(speed
)], snmp_status
, detailOutput
),
222 return (3, "item not found in snmp data")
226 # .--mem-----------------------------------------------------------------.
228 # | _ __ ___ ___ _ __ ___ |
229 # | | '_ ` _ \ / _ \ '_ ` _ \ |
230 # | | | | | | | __/ | | | | | |
231 # | |_| |_| |_|\___|_| |_| |_| |
233 # '----------------------------------------------------------------------'
235 hp_proliant_mem_type_map
= {
238 3: 'cpqSingleWidthModule',
239 4: 'cpqDoubleWidthModule',
242 7: 'compaq-specific',
244 9: 'smallOutlineDimm',
256 hp_proliant_mem_status_map
= {
272 hp_proliant_mem_status2nagios_map
= {
289 hp_proliant_mem_condition_status2nagios_map
= {
294 'degradedModuleIndexUnknown': 3
297 hp_proliant_mem_condition_map
= {
302 4: 'degradedModuleIndexUnknown',
306 def inventory_hp_proliant_mem(info
):
308 return [ (line
[1], None) for line
in info
if line
[2].isdigit() and \
309 int(line
[2]) > 0 and int(line
[4]) != 2 ]
312 def check_hp_proliant_mem(item
, params
, info
):
315 board_index
, module_index
, module_size
, module_type
, \
316 module_status
, module_condition
= line
318 module_size_mb
= int(module_size
) / 1024
321 if int(module_type
) in hp_proliant_mem_type_map
:
322 type_
= hp_proliant_mem_type_map
[int(module_type
)]
325 if int(module_status
) in hp_proliant_mem_status_map
:
326 snmp_status
= hp_proliant_mem_status_map
[int(module_status
)]
328 detail_output
= ', Status: %s ' % snmp_status
329 status
= hp_proliant_mem_status2nagios_map
[snmp_status
]
333 detail_output
+= '(!) '
335 detail_output
+= '(!!) '
337 detail_output
+= '(?) '
340 if saveint(module_condition
) in hp_proliant_mem_condition_map
:
341 condition
= hp_proliant_mem_condition_map
[saveint(module_condition
)]
342 condition_status
= hp_proliant_mem_condition_status2nagios_map
[condition
]
344 detail_output
+= ', Condition: %s ' % condition
345 if condition_status
== 0:
347 elif condition_status
== 1:
348 detail_output
+= '(!) '
349 elif condition_status
== 2:
350 detail_output
+= '(!!) '
352 detail_output
+= '(?) '
353 if condition_status
> status
:
354 status
= condition_status
356 return (status
, 'Board: %s, Num: %s, Type: %s, Size: %s MB%s' %
357 (board_index
, module_index
, type_
, module_size_mb
, detail_output
))
358 return (3, "item not found in snmp data")
362 # .--temperature---------------------------------------------------------.
364 # | | |_ ___ _ __ ___ _ __ ___ _ __ __ _| |_ _ _ _ __ ___ |
365 # | | __/ _ \ '_ ` _ \| '_ \ / _ \ '__/ _` | __| | | | '__/ _ \ |
366 # | | || __/ | | | | | |_) | __/ | | (_| | |_| |_| | | | __/ |
367 # | \__\___|_| |_| |_| .__/ \___|_| \__,_|\__|\__,_|_| \___| |
369 # '----------------------------------------------------------------------'
372 def format_hp_proliant_name(line
):
373 return "%s (%s)" % (line
[0], hp_proliant_locale
[int(line
[1])])
376 def inventory_hp_proliant_temp(info
):
378 yield format_hp_proliant_name(line
), {}
381 def check_hp_proliant_temp(item
, params
, info
):
383 if format_hp_proliant_name(line
) == item
:
384 value
, threshold
, status
= line
[2:]
386 # This case means no threshold available and
387 # the devices' web interface displays "N/A"
388 if threshold
== "-99" or threshold
== "0":
391 threshold
= float(threshold
)
392 devlevels
= (threshold
, threshold
)
394 snmp_status
= hp_proliant_status_map
[int(status
)]
396 return check_temperature(
399 "hp_proliant_temp_%s" % item
,
400 dev_levels
=devlevels
,
401 dev_status
=hp_proliant_status2nagios_map
[snmp_status
],
402 dev_status_name
="Unit: %s" % snmp_status
)
403 return 3, "item not found in snmp data"