Cleanup config.nodes_of
[check_mk.git] / checks / blade_bays
blob79a19a991a880a534cbedb725644c22c8a58d397
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
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):
29 map_states = {
30 "0": (0, 'standby'),
31 "1": (0, 'on'),
32 "2": (1, 'not present'),
33 "3": (1, 'switched off'),
34 "255": (2, 'not applicable'),
37 parsed = {}
38 for pd_oidend, name, state, ty, identifier, \
39 power_str, power_max_str in info:
40 pd, oid = pd_oidend.split(".", 1)
41 if pd == '2':
42 power_domain = 1
43 else:
44 power_domain = 2
46 itemname = "PD%d %s" % (power_domain, name)
47 if itemname in parsed:
48 itemname = "%s %s" % (itemname, oid)
50 try:
51 power = int(power_str.rstrip("W"))
52 power_max = int(power_max_str.rstrip("W"))
53 except ValueError:
54 power = 0
56 parsed.setdefault(
57 itemname, {
58 "type": ty.split("(")[0],
59 "id": identifier,
60 "power_max": power_max,
61 "device_state": map_states.get(state, (3, "unhandled[%s]" % state)),
62 "power": power,
65 return parsed
68 def inventory_blade_bays(parsed):
69 for entry, attrs in parsed.items():
70 if attrs["device_state"][1] in ["standby", "on"]:
71 yield entry, {}
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
77 return
79 data = parsed[item]
80 state, state_readable = data["device_state"]
81 yield state, "Status: %s" % state_readable
83 for res in check_elphase(item, params, parsed):
84 yield res
86 data = parsed[item]
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", [
98 "2", # powerDomain1
99 "3", # powerDomain2
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' ],