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 # 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.
28 def parse_blade_bays(info
):
32 "2": (1, 'not present'),
33 "3": (1, 'switched off'),
34 "255": (2, 'not applicable'),
38 for pd_oidend
, name
, state
, ty
, identifier
, \
39 power_str
, power_max_str
in info
:
40 pd
, oid
= pd_oidend
.split(".", 1)
46 itemname
= "PD%d %s" % (power_domain
, name
)
47 if itemname
in parsed
:
48 itemname
= "%s %s" % (itemname
, oid
)
51 power
= int(power_str
.rstrip("W"))
52 power_max
= int(power_max_str
.rstrip("W"))
58 "type": ty
.split("(")[0],
60 "power_max": power_max
,
61 "device_state": map_states
.get(state
, (3, "unhandled[%s]" % state
)),
68 def inventory_blade_bays(parsed
):
69 for entry
, attrs
in parsed
.items():
70 if attrs
["device_state"][1] in ["standby", "on"]:
74 def check_blade_bays(item
, params
, parsed
):
75 if item
not in parsed
:
76 yield 3, "No data for '%s' in SNMP info" % item
80 state
, state_readable
= data
["device_state"]
81 yield state
, "Status: %s" % state_readable
83 for res
in check_elphase(item
, params
, parsed
):
87 yield 0, "Max. power: %s W, Type: %s, ID: %s" % \
88 (data
["power_max"], data
["type"], data
["id"])
91 check_info
["blade_bays"] = {
92 'parse_function' : parse_blade_bays
,
93 'inventory_function' : inventory_blade_bays
,
94 'check_function' : check_blade_bays
,
95 'service_description' : 'BAY %s',
96 'has_perfdata' : True,
97 'snmp_info' : ( ".1.3.6.1.4.1.2.3.51.2.2.10", [
100 ], [ OID_END
, "1.1.5", "1.1.6", "1.1.2", "1.1.1", "1.1.7", "1.1.8" ] ), # BLADE-MIB
101 'snmp_scan_function' : lambda oid
: \
102 re
.match('(BladeCenter|BladeCenter Advanced|IBM Flex Chassis|Lenovo Flex Chassis) Management Module', oid(".1.3.6.1.2.1.1.1.0")) is not None,
103 'includes' : [ 'elphase.include' ],