Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / dell_idrac_power
blob7f0d3256fac795ab50f0a118238424b89eaad930
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2017 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 # example output
30 def inventory_dell_idrac_power(info):
31 for index, _status, _count in info[0]:
32 yield index, None
35 def check_dell_idrac_power(item, _no_params, info):
36 translate_status = {
37 "1": (3, "other"),
38 "2": (3, "unknown"),
39 "3": (0, "full"),
40 "4": (1, "degraded"),
41 "5": (2, "lost"),
42 "6": (0, "not redundant"),
43 "7": (1, "redundancy offline"),
46 for index, status, _count in info[0]:
47 if index == item:
48 state, state_readable = translate_status[status]
49 yield state, "Status: %s" % state_readable
52 check_info['dell_idrac_power'] = {
53 'inventory_function': inventory_dell_idrac_power,
54 'check_function': check_dell_idrac_power,
55 'service_description': 'Power Supply Redundancy %s',
56 'snmp_info': [
58 '.1.3.6.1.4.1.674.10892.5.4.600.10.1',
60 "2", # IDRAC-MIB::powerUnitIndex
61 "5", # IDRAC-MIB::powerUnitRedundancyStatus
62 "6", # IDRAC-MIB::powerSupplyCountForRedundancy
63 ]),
65 '.1.3.6.1.4.1.674.10892.5.4.600.12.1',
67 "2", # IDRAC-MIB::powerSupplyIndex
68 "5", # IDRAC-MIB::powerSupplyStatus
69 "7", # IDRAC-MIB::powerSupplyType
70 "8", # IDRAC-MIB::powerSupplyLocationName
71 ]),
73 'snmp_scan_function':
74 lambda oid: oid('.1.3.6.1.2.1.1.2.0').startswith(".1.3.6.1.4.1.674.10892.5"),
78 def inventory_dell_idrac_power_unit(info):
79 for index, _status, _psu_type, _location in info[1]:
80 yield index, None
83 def check_dell_idrac_power_unit(item, _no_params, info):
84 translate_status = {
85 "1": (3, "OTHER"),
86 "2": (3, "UNKNOWN"),
87 "3": (0, "OK"),
88 "4": (1, "NONCRITICAL"),
89 "5": (2, "CRITICAL"),
90 "6": (2, "NONRECOVERABLE"),
93 translate_type = {
94 "1": "OTHER",
95 "2": "UNKNOWN",
96 "3": "LINEAR",
97 "4": "SWITCHING",
98 "5": "BATTERY",
99 "6": "UPS",
100 "7": "CONVERTER",
101 "8": "REGULATOR",
102 "9": "AC",
103 "10": "DC",
104 "11": "VRM",
107 for index, status, psu_type, location in info[1]:
108 if index == item:
109 state, state_readable = translate_status[status]
110 psu_type_readable = translate_type[psu_type]
111 yield state, "Status: %s, Type: %s, Name: %s" % \
112 ( state_readable, psu_type_readable, location )
115 check_info['dell_idrac_power.unit'] = {
116 'inventory_function': inventory_dell_idrac_power_unit,
117 'check_function': check_dell_idrac_power_unit,
118 'service_description': 'Power Supply %s',