Cleanup config.nodes_of
[check_mk.git] / checks / dell_powerconnect_psu
blob54f76dc43574b27c101da84babe7079852e3904f
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 # Tested with Dell PowerConnect 5448 and 5424 models.
28 # Relevant SNMP OIDs:
29 # .1.3.6.1.4.1.674.10895.3000.1.2.110.7.2.1.1.67109185 = INTEGER: 67109185
30 # .1.3.6.1.4.1.674.10895.3000.1.2.110.7.2.1.1.67109186 = INTEGER: 67109186
31 # .1.3.6.1.4.1.674.10895.3000.1.2.110.7.2.1.2.67109185 = STRING: "ps1_unit1"
32 # .1.3.6.1.4.1.674.10895.3000.1.2.110.7.2.1.2.67109186 = STRING: "ps2_unit1"
33 # .1.3.6.1.4.1.674.10895.3000.1.2.110.7.2.1.3.67109185 = INTEGER: 1
34 # .1.3.6.1.4.1.674.10895.3000.1.2.110.7.2.1.3.67109186 = INTEGER: 5
35 # .1.3.6.1.4.1.674.10895.3000.1.2.110.7.2.1.4.67109185 = INTEGER: 5
36 # .1.3.6.1.4.1.674.10895.3000.1.2.110.7.2.1.4.67109186 = INTEGER: 4
38 # Status codes:
39 # 1 => normal,
40 # 2 => warning,
41 # 3 => critical,
42 # 4 => shutdown,
43 # 5 => notPresent,
44 # 6 => notFunctioning
46 # Supply Source Codes:
47 # 1 => unknown
48 # 2 => ac
49 # 3 => dc
50 # 4 => externalPowerSupply
51 # 5 => internalRedundant
53 # GENERAL MAPS:
54 dell_powerconnect_psu_status_map = {
55 '1': 'normal',
56 '2': 'warning',
57 '3': 'critical',
58 '4': 'shutdown',
59 '5': 'notPresent',
60 '6': 'notFunctioning',
63 dell_powerconnect_psu_supply_map = {
64 '1': 'Unknown',
65 '2': 'Alternating Current',
66 '3': 'Direct Current',
67 '4': 'External Power Supply',
68 '5': 'Internal Redundant',
71 dell_powerconnect_psu_status2nagios_map = {
72 'normal': 0,
73 'warning': 1,
74 'critical': 2,
75 'shutdown': 3,
76 'notPresent': 1,
77 'notFunctioning': 2,
81 def inventory_dell_powerconnect_psu(checkname, info):
82 inventory = []
83 if not info or not info[0]:
84 return
85 hw_ident = info[0][0][0]
86 for _device_id, name, state, _supply in info[1]:
87 # M6220 are blade switches which report valid values only for the "Main"
88 # sensor. The other one is reported as notFunctioning, but this is wrong.
89 # Simply ignore the "System" sensor for those devices.
90 if dell_powerconnect_psu_status_map[state] != 'notPresent' \
91 and ('M6220' not in hw_ident or name != 'System'):
92 inventory.append((name, None))
93 return inventory
96 def check_dell_powerconnect_psu(item, _not_used, info):
97 for _device_id, name, state, supply in info[1]:
98 if name == item:
99 dell_powerconnect_status = dell_powerconnect_psu_status_map[state]
100 status = dell_powerconnect_psu_status2nagios_map[dell_powerconnect_status]
102 return status, 'Condition is %s, with source %s' % \
103 (dell_powerconnect_status, dell_powerconnect_psu_supply_map[supply])
105 return (3, "item not found in snmp data")
107 check_info["dell_powerconnect_psu"] = {
108 'check_function': check_dell_powerconnect_psu,
109 'inventory_function': inventory_dell_powerconnect_psu,
110 'service_description': 'Sensor %s',
111 'snmp_info': [('.1.3.6.1.4.1.674.10895.3000.1.2.100.1', ['0']), #productIdentificationDisplayName
112 ('.1.3.6.1.4.1.674.10895.3000.1.2.110.7.2.1', [
113 '1', # envMonSupplyStatusIndex
114 '2', # envMonSupplyStatusDescr
115 '3', # envMonSupplyState
116 '4', # envMonSupplySource
117 ])],
118 'snmp_scan_function': lambda oid: ".1.3.6.1.4.1.674.10895" in oid(".1.3.6.1.2.1.1.2.0") or \
119 ".1.3.6.1.4.1.6027.1.3.22" in oid(".1.3.6.1.2.1.1.2.0"),