Refactoring: Moved check parameters from unsorted.py to dedicated modules (CMK-1393)
[check_mk.git] / checks / dell_om_power
blobf686ac65762ca9224c9566108eab82932b6a3675
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
28 # .1.3.6.1.4.1.674.10892.1.600.10.1.2.1.1 1
29 # .1.3.6.1.4.1.674.10892.1.600.10.1.5.1.1 3
30 # .1.3.6.1.4.1.674.10892.1.600.10.1.6.1.1 0
31 # .1.3.6.1.4.1.674.10892.1.600.12.1.2.1.1 1
32 # .1.3.6.1.4.1.674.10892.1.600.12.1.2.1.2 2
33 # .1.3.6.1.4.1.674.10892.1.600.12.1.5.1.1 3
34 # .1.3.6.1.4.1.674.10892.1.600.12.1.5.1.2 3
35 # .1.3.6.1.4.1.674.10892.1.600.12.1.7.1.1 9
36 # .1.3.6.1.4.1.674.10892.1.600.12.1.7.1.2 9
37 # .1.3.6.1.4.1.674.10892.1.600.12.1.8.1.1 PS1 Status
38 # .1.3.6.1.4.1.674.10892.1.600.12.1.8.1.2 PS2 Status
41 def inventory_dell_om_power(info):
42 for index, _status, _count in info[0]:
43 yield (index, None)
46 def check_dell_om_power(item, params, info):
47 translate_status = {
48 "1": (3, "other"),
49 "2": (3, "unknown"),
50 "3": (0, "full"),
51 "4": (1, "degraded"),
52 "5": (2, "lost"),
53 "6": (0, "not redundant"),
54 "7": (1, "redundancy offline"),
57 for index, status, _count in info[0]:
58 if index == item:
59 state, state_readable = translate_status[status]
60 yield state, "Redundancy status: %s" % state_readable
63 check_info['dell_om_power'] = {
64 'inventory_function': inventory_dell_om_power,
65 'check_function': check_dell_om_power,
66 'service_description': 'Power Supply Redundancy %s',
67 'snmp_info': [
69 '.1.3.6.1.4.1.674.10892.1.600.10.1',
71 "2", # MIB-Dell-10892::powerUnitIndex
72 "5", # MIB-Dell-10892::powerUnitRedundancyStatus
73 "6", # MIB-Dell-10892::powerSupplyCountForRedundancy
74 ]),
76 '.1.3.6.1.4.1.674.10892.1.600.12.1',
78 "2", # MIB-Dell-10892::powerSupplyIndex
79 "5", # MIB-Dell-10892::powerSupplyStatus
80 "7", # MIB-Dell-10892::powerSupplyType
81 "8", # MIB-Dell-10892::powerSupplyLocationName
82 ]),
84 'snmp_scan_function': scan_dell_om,
85 'includes': ["dell_om.include"],
89 def inventory_dell_om_power_unit(info):
90 for line in info[1]:
91 yield (line[0], None)
94 def check_dell_om_power_unit(item, _no_params, info):
95 translate_status = {
96 "1": (3, "OTHER"),
97 "2": (3, "UNKNOWN"),
98 "3": (0, "OK"),
99 "4": (1, "NONCRITICAL"),
100 "5": (2, "CRITICAL"),
101 "6": (2, "NONRECOVERABLE"),
104 translate_type = {
105 "1": "OTHER",
106 "2": "UNKNOWN",
107 "3": "LINEAR",
108 "4": "SWITCHING",
109 "5": "BATTERY",
110 "6": "UPS",
111 "7": "CONVERTER",
112 "8": "REGULATOR",
113 "9": "AC",
114 "10": "DC",
115 "11": "VRM",
118 for index, status, psu_type, location in info[1]:
119 if index == item:
120 state, state_readable = translate_status[status]
121 psu_type_readable = translate_type[psu_type]
122 yield state, "Status: %s, Type: %s, Name: %s" % \
123 ( state_readable, psu_type_readable, location )
126 check_info['dell_om_power.unit'] = {
127 'inventory_function': inventory_dell_om_power_unit,
128 'check_function': check_dell_om_power_unit,
129 'service_description': 'Power Supply %s',