2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
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 # Example output from agent:
28 # [['1', '24', 'SLOT #0: TEMP #1'],
29 # ['2', '12', 'SLOT #0: TEMP #2'],
30 # ['3', '12', 'SLOT #0: TEMP #3'],
31 # ['4', '4687', 'FAN #1'],
32 # ['5', '4560', 'FAN #2'],
33 # ['6', '4821', 'FAN #3'],
34 # ['7', '1', 'Power Supply #1'],
35 # ['8', '1', 'Power Supply #2']]
38 def brocade_sensor_convert(info
, what
):
40 for presence
, state
, name
in info
:
41 name
= name
.lstrip() # remove leading spaces provided via SNMP
42 if name
.startswith(what
) and presence
!= "6" and (saveint(state
) > 0 or what
== "Power"):
43 sensor_id
= name
.split('#')[-1]
44 return_list
.append([sensor_id
, name
, state
])
48 def brocade_scan(oid
):
49 return oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.1588.2.1.1") or \
50 oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.24.1.1588.2.1.1") or \
51 oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.1588.2.2.1") or \
52 oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.1588.3.3.1")
56 '.1.3.6.1.4.1.1588.2.1.1.1.1.22.1',
58 3, # swSensorStatus, 6 = absent
59 4, # swSensorValue, -2147483648 = unknown
63 brocade_fan_default_levels
= {"lower": (3000, 2800)}
66 def inventory_brocade_fan(info
):
67 converted
= brocade_sensor_convert(info
, "FAN")
68 return [(x
[0], 'brocade_fan_default_levels') for x
in converted
]
71 def check_brocade_fan(item
, params
, info
):
72 converted
= brocade_sensor_convert(info
, "FAN")
73 if isinstance(params
, tuple): # old format
74 params
= {"lower": params
}
76 for snmp_item
, _name
, value
in converted
:
78 return check_fan(int(value
), params
)
81 check_info
["brocade.fan"] = {
82 "check_function": check_brocade_fan
,
83 "inventory_function": inventory_brocade_fan
,
84 "service_description": "FAN %s",
86 "snmp_info": brocade_info
,
87 "snmp_scan_function": brocade_scan
,
89 "includes": ["fan.include"],
93 def inventory_brocade_power(info
):
94 converted
= brocade_sensor_convert(info
, "Power")
95 return [(x
[0], None) for x
in converted
]
98 def check_brocade_power(item
, _no_params
, info
):
99 converted
= brocade_sensor_convert(info
, "Power")
100 for snmp_item
, name
, value
in converted
:
101 if item
== snmp_item
:
104 return 2, "Error on supply %s" % name
105 return 0, "No problems found"
107 return 3, "Supply not found"
110 check_info
["brocade.power"] = {
111 "check_function": check_brocade_power
,
112 "inventory_function": inventory_brocade_power
,
113 "service_description": "Power supply %s",
114 "snmp_info": brocade_info
,
115 'snmp_scan_function': brocade_scan
,
118 factory_settings
["brocade_temp_default_levels"] = {"levels": (55, 60)}
121 def inventory_brocade_temp(info
):
122 converted
= brocade_sensor_convert(info
, "SLOT")
123 return [(x
[0], 'brocade_temp_default_levels') for x
in converted
]
126 def check_brocade_temp(item
, params
, info
):
127 converted
= brocade_sensor_convert(info
, "SLOT")
128 for snmp_item
, _name
, value
in converted
:
129 if item
== snmp_item
:
130 return check_temperature(int(value
), params
, "brocade_temp_%s" % item
)
133 check_info
["brocade.temp"] = {
134 "check_function": check_brocade_temp
,
135 "inventory_function": inventory_brocade_temp
,
136 "service_description": "Temperature Ambient %s",
137 "has_perfdata": True,
138 "group": "temperature",
139 "snmp_info": brocade_info
,
140 'snmp_scan_function': brocade_scan
,
141 "default_levels_variable": "brocade_temp_default_levels",
142 "includes": ["temperature.include"],