2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
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.
28 def parse_brocade_sfp(info
):
31 isl_ports
= [int(x
[0]) for x
in info
[1]]
33 for fcport_info
, values
in zip(info
[0], info
[2]):
35 # Observed in the wild: Either all of the values are present
40 port_index
= int(fcport_info
[0])
42 parsed
[port_index
] = {
43 "port_name": fcport_info
[4],
44 "temp": int(values
[0]), # °C
45 "phystate": int(fcport_info
[1]),
46 "opstate": int(fcport_info
[2]),
47 "admstate": int(fcport_info
[3]),
48 "voltage": float(values
[1]) / 1000, # mV -> V
49 "current": float(values
[2]) / 1000, # mA -> A
50 "rx_power": float(values
[3]), # dBm
51 "tx_power": float(values
[4]), # dBm
52 "is_isl": bool(port_index
in isl_ports
),
58 def inventory_brocade_sfp(parsed
):
59 settings
= host_extra_conf_merged(host_name(), brocade_fcport_inventory
)
60 number_of_ports
= len(parsed
)
61 for port_index
, port_info
in parsed
.iteritems():
62 if brocade_fcport_inventory_this_port(
63 admstate
=port_info
["admstate"],
64 phystate
=port_info
["phystate"],
65 opstate
=port_info
["opstate"],
67 yield brocade_fcport_getitem(
68 number_of_ports
=number_of_ports
,
70 portname
=port_info
["port_name"],
71 is_isl
=port_info
["is_isl"],
72 settings
=settings
), {}
75 # .--Temperature---------------------------------------------------------.
77 # | |_ _|__ _ __ ___ _ __ ___ _ __ __ _| |_ _ _ _ __ ___ |
78 # | | |/ _ \ '_ ` _ \| '_ \ / _ \ '__/ _` | __| | | | '__/ _ \ |
79 # | | | __/ | | | | | |_) | __/ | | (_| | |_| |_| | | | __/ |
80 # | |_|\___|_| |_| |_| .__/ \___|_| \__,_|\__|\__,_|_| \___| |
82 # '----------------------------------------------------------------------'
85 def check_brocade_sfp_temp(item
, params
, parsed
):
87 port_index
= int(item
.split()[0]) + 1 # TODO: Move this magical plucking apart of the
88 port_info
= parsed
[port_index
] # item to brocade.include and do the same
91 return check_temperature(port_info
["temp"], params
, item
)
94 check_info
['brocade_sfp.temp'] = {
95 'inventory_function': inventory_brocade_sfp
,
96 'check_function': check_brocade_sfp_temp
,
97 'service_description': "SFP Temperature %s",
99 'group': "temperature",
100 'includes': ["brocade.include", "temperature.include"],
104 # .--Power level - Main check--------------------------------------------.
106 # | | _ \ _____ _____ _ __ | | _____ _____| | |
107 # | | |_) / _ \ \ /\ / / _ \ '__| | |/ _ \ \ / / _ \ | |
108 # | | __/ (_) \ V V / __/ | | | __/\ V / __/ | |
109 # | |_| \___/ \_/\_/ \___|_| |_|\___| \_/ \___|_| |
111 # +----------------------------------------------------------------------+
112 # | Also includes information about current and voltage |
113 # '----------------------------------------------------------------------'
116 def check_brocade_sfp(item
, params
, parsed
):
118 # NOTE: We do not use the generic check_levels function from
119 # the API because its behaviour is undesirable, such as
120 # not providing an infotext or perfdata when no levels
122 def check_levels(value
, perf_name
, params
, infotext_prefix
, unit
):
123 infotext
= infotext_prefix
+ ("%.2f %s" % (value
, unit
))
125 return 0, infotext
, [(perf_name
, value
)]
127 crit_lower
, warn_lower
, warn
, crit
= params
128 perfdata
= [(perf_name
, value
, warn
, crit
)]
129 if value
>= crit
or value
< crit_lower
:
131 elif value
>= warn
or value
< warn_lower
:
135 return status
, infotext
, perfdata
137 port_index
= int(item
.split()[0]) + 1 # TODO: Move this magical plucking apart of the
138 port_info
= parsed
[port_index
] # item to brocade.include and do the same
139 # for brocade.fcport.
141 yield check_levels(port_info
["rx_power"], "input_signal_power_dbm", params
.get("rx_power"),
143 yield check_levels(port_info
["tx_power"], "output_signal_power_dbm", params
.get("tx_power"),
145 yield check_levels(port_info
["current"], "current", params
.get("current"), "current: ", "A")
146 yield check_levels(port_info
["voltage"], "voltage", params
.get("voltage"), "voltage: ", "V")
149 check_info
['brocade_sfp'] = {
150 'parse_function' : parse_brocade_sfp
,
151 'inventory_function' : inventory_brocade_sfp
,
152 'check_function' : check_brocade_sfp
,
153 'service_description' : 'SFP %s',
154 'snmp_scan_function' : lambda oid
: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.1588.2.1.1") \
155 and oid(".1.3.6.1.4.1.1588.2.1.1.1.6.2.1.*") is not None,
156 'snmp_info' : [ ( ".1.3.6.1.4.1.1588.2.1.1.1.6.2.1", [
157 CACHED_OID("1"), # swFCPortIndex
158 CACHED_OID("3"), # swFCPortPhyState
159 CACHED_OID("4"), # swFCPortOpStatus
160 CACHED_OID("5"), # swFCPortAdmStatus
161 CACHED_OID("36"), # swFCPortName (not supported by all devices)
164 # Information about Inter-Switch-Links (contains baud rate of port)
165 ( ".1.3.6.1.4.1.1588.2.1.1.1.2.9.1", [
166 CACHED_OID("2"), # swNbMyPort
169 # NOTE: It appears that the port name and index in connUnitPortEntry
170 # are identical to the ones in the table used by
171 # brocade_fcport. We work on this assumption for the time being,
172 # meaning we use the same table as in brocade_fcport (see above)
173 # which we need anyway for PhyState, OpStatus and AdmStatus.
174 # Please check the connUnitPortEntry table (.1.3.6.1.3.94.1.10.1)
175 # should you come across a device for which this assumption
177 ('.1.3.6.1.4.1.1588.2.1.1.1.28.1.1', [ # FA-EXT-MIB::swSfpStatEntry
178 # AUGMENTS {connUnitPortEntry}
179 "1", # swSfpTemperature
186 'has_perfdata' : True,
187 'includes' : [ "brocade.include" ],
188 'group' : "brocade_sfp",