Cleanup config.nodes_of
[check_mk.git] / checks / alcatel_power_aos7
blob5dba3ba5ec9deb28508e809e85133edeb172a057
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2019 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_aos7_operability_to_status_mapping = {
28 '1': "up",
29 '2': "down",
30 '3': "testing",
31 '4': "unknown",
32 '5': "secondary",
33 '6': "not present", # no check status required
34 '7': "unpowered",
35 '8': "master",
36 '9': "idle",
37 '10': "power save",
40 alcatel_power_aos7_no_power_supply = "no power supply"
42 alcatel_power_aos7_power_type_mapping = {
43 '0': alcatel_power_aos7_no_power_supply,
44 '1': "AC",
45 '2': "DC",
48 PowerSupplyEntry = collections.namedtuple('PowerSupplyEntry', 'status_readable power_supply_type')
51 def parse_alcatel_power_aos7(info):
52 return {
53 item: PowerSupplyEntry(
54 alcatel_power_aos7_operability_to_status_mapping[operability_status],
55 alcatel_power_aos7_power_type_mapping[power_supply_type],
56 ) for (item, operability_status, power_supply_type) in info
60 @discover
61 def inventory_alcatel_power_aos7(_oidend, device):
62 return (device.power_supply_type != alcatel_power_aos7_no_power_supply and
63 device.status_readable != "not present")
66 @get_parsed_item_data
67 def check_alcatel_power_aos7(item, _no_params, device):
68 if device.status_readable == 'up':
69 status = 0
70 else:
71 status = 2
72 yield status, "[%s] Status: %s" % (device.power_supply_type, device.status_readable)
75 check_info["alcatel_power_aos7"] = {
76 "parse_function": parse_alcatel_power_aos7,
77 "check_function": check_alcatel_power_aos7,
78 "inventory_function": inventory_alcatel_power_aos7,
79 "service_description": "Power Supply %s",
80 "snmp_scan_function": alcatel_new_networking_products_scan_function,
81 "snmp_info": (
82 ".1.3.6.1.4.1.6486.801.1.1.1.1.1.1.1", # MIB object "chasEntPhysicalEntry"
84 OID_END,
85 2, # MIB object "chasEntPhysOperStatus"
86 35, # MIB object "chasEntPhysPowerType"
87 ]),
88 "includes": ["alcatel.include"],