Cleanup config.nodes_of
[check_mk.git] / checks / alcatel_power
blob036ec3fd923f3b6f97c2d5ac0400c7c9f696ec98
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.
27 alcatel_power_operstate_map = {
28 "1": "up",
29 "2": "down",
30 "3": "testing",
31 "4": "unknown",
32 "5": "secondary",
33 "6": "not present",
34 "7": "unpowered",
35 "9": "master",
38 alcatel_power_no_power_supply_info = "no power supply"
40 alcatel_power_type_map = {
41 "0": alcatel_power_no_power_supply_info,
42 "1": "AC",
43 "2": "DC",
46 AlcatelPowerEntry = collections.namedtuple("AlcatelPowerEntry", [
47 "oper_state_readable",
48 "power_type",
52 def parse_alcatel_power(info):
53 parsed = {}
54 for oidend, status, power_type in info:
55 parsed.setdefault(
56 oidend,
57 AlcatelPowerEntry(
58 alcatel_power_operstate_map.get(status, 'unknown[%s]' % status),
59 alcatel_power_type_map.get(power_type, alcatel_power_no_power_supply_info),
61 return parsed
64 @discover
65 def inventory_alcatel_power(_oidend, device):
66 return (device.power_type != alcatel_power_no_power_supply_info and
67 device.oper_state_readable != 'not present')
70 @get_parsed_item_data
71 def check_alcatel_power(item, _no_params, device):
72 if device.oper_state_readable == 'up':
73 state = 0
74 else:
75 state = 2
76 yield state, "[%s] Operational status: %s" % (device.power_type, device.oper_state_readable)
79 check_info["alcatel_power"] = {
80 "parse_function": parse_alcatel_power,
81 "check_function": check_alcatel_power,
82 "inventory_function": inventory_alcatel_power,
83 "service_description": "Power Supply %s",
84 "snmp_scan_function": alcatel_networking_products_scan_function,
85 "snmp_info": (
86 ".1.3.6.1.4.1.6486.800.1.1.1.1.1.1.1", # MIB object "chasEntPhysicalEntry"
88 OID_END,
89 2, # MIB object "chasEntPhysOperStatus":
90 # up(1), down(2), testing(3), unknown(4),
91 # secondary(5), notPresent(6), unpowered(7), master(9)
92 36, # MIB object "chasEntPhysPowerType":
93 # 0 no power supply, 1 ac, 2 dc (not available on old devices)
94 ]),
95 "includes": ["alcatel.include"],