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 # settings for inventory: which ports should be inventorized
28 qlogic_fcport_inventory_opstates
= ["1", "3"]
29 qlogic_fcport_inventory_admstates
= ["1", "3"]
32 # this function is needed to have the same port IDs in Check_MK
33 # as within the Management interface of the device
34 def qlogic_fcport_generate_port_id(port_id
):
35 major
, minor
= port_id
.split(".", 1)
36 minor
= int(minor
) - 1
37 port_id
= "%s.%s" % (major
, minor
)
41 def inventory_qlogic_fcport(info
):
44 for port_id
, _oper_mode
, admin_status
, oper_status
, _link_failures
, \
45 _sync_losses
, _prim_seq_proto_errors
, _invalid_tx_words
, _invalid_crcs
, \
46 _address_id_errors
, _link_reset_ins
, _link_reset_outs
, _ols_ins
, \
47 _ols_outs
, _c2_in_frames
, _c2_out_frames
, _c2_in_octets
, _c2_out_octets
, \
48 _c2_discards
, _c2_fbsy_frames
, _c2_frjt_frames
, _c3_in_frames
, \
49 _c3_out_frames
, _c3_in_octets
, _c3_out_octets
, _c3_discards
in info
:
51 # There are devices out there which are totally missing the status related
52 # SNMP tables. In this case we add all interfaces.
53 if (admin_status
== '' and oper_status
== '') \
54 or (admin_status
in qlogic_fcport_inventory_admstates
and \
55 oper_status
in qlogic_fcport_inventory_opstates
):
56 inventory
.append((qlogic_fcport_generate_port_id(port_id
), None))
61 def check_qlogic_fcport(item
, params
, info
):
62 for port_id
, oper_mode
, admin_status
, oper_status
, link_failures
, \
63 sync_losses
, prim_seq_proto_errors
, invalid_tx_words
, invalid_crcs
, \
64 address_id_errors
, link_reset_ins
, link_reset_outs
, ols_ins
, \
65 ols_outs
, c2_in_frames
, c2_out_frames
, c2_in_octets
, c2_out_octets
, \
66 c2_discards
, c2_fbsy_frames
, c2_frjt_frames
, c3_in_frames
, \
67 c3_out_frames
, c3_in_octets
, c3_out_octets
, c3_discards
in info
:
69 port_id
= qlogic_fcport_generate_port_id(port_id
)
73 message
= "Port %s" % port_id
75 # fcFxPortPhysAdminStatus
76 if admin_status
== "1":
77 message
+= " AdminStatus: online"
79 elif admin_status
== "2":
80 message
+= " AdminStatus: offline (!!)"
82 elif admin_status
== "3":
83 message
+= " AdminStatus: testing (!)"
85 elif admin_status
== "":
86 # Is not a possible valid value in the MIB, but some devices don't
87 # provide status information at all (SNMP table missing).
88 message
+= " AdminStatus: not reported"
91 message
+= " unknown AdminStatus %s (!)" % admin_status
94 # fcFxPortPhysOperStatus
95 if oper_status
== "1":
96 message
+= ", OperStatus: online"
97 status
= max(status
, 0)
98 elif oper_status
== "2":
99 message
+= ", OperStatus: offline (!!)"
100 status
= max(status
, 2)
101 elif oper_status
== "3":
102 message
+= ", OperStatus: testing (!)"
103 status
= max(status
, 1)
104 elif oper_status
== "4":
105 message
+= ", OperStatus: linkFailure (!!)"
106 status
= max(status
, 2)
107 elif admin_status
== "":
108 # Is not a possible valid value in the MIB, but some devices don't
109 # provide status information at all (SNMP table missing).
110 message
+= ", OperStatus: not reported"
113 message
+= ", unknown OperStatus %s (!)" % oper_status
114 status
= max(status
, 1)
116 # fcFxPortOperMode (for display only)
118 message
+= ", OperMode: fPort"
119 elif oper_mode
== "3":
120 message
+= ", OperMode: flPort"
123 this_time
= time
.time()
125 # Bytes/sec in and out
126 in_octets
= int(c2_in_octets
) + int(c3_in_octets
)
127 out_octets
= int(c2_out_octets
) + int(c3_out_octets
)
129 in_octet_rate
= get_rate("qlogic_fcport.in_octets.%s" % port_id
, this_time
, in_octets
)
130 out_octet_rate
= get_rate("qlogic_fcport.out_octets.%s" % port_id
, this_time
,
133 message
+= ", In: %s/s" % get_bytes_human_readable(in_octet_rate
)
134 message
+= ", Out: %s/s" % get_bytes_human_readable(out_octet_rate
)
136 perfdata
.append(("in", in_octet_rate
))
137 perfdata
.append(("out", out_octet_rate
))
140 in_frames
= int(c2_in_frames
) + int(c3_in_frames
)
141 out_frames
= int(c2_out_frames
) + int(c3_out_frames
)
143 in_frame_rate
= get_rate("qlogic_fcport.in_frames.%s" % port_id
, this_time
, in_frames
)
144 out_frame_rate
= get_rate("qlogic_fcport.out_frames.%s" % port_id
, this_time
,
147 message
+= ", in frames: %s/s" % in_frame_rate
148 message
+= ", out frames: %s/s" % out_frame_rate
150 perfdata
.append(("rxframes", in_frame_rate
))
151 perfdata
.append(("txframes", out_frame_rate
))
154 discards
= int(c2_discards
) + int(c3_discards
)
156 for descr
, counter
, value
in [
157 ("Link Failures", "link_failures", link_failures
),
158 ("Sync Losses", "sync_losses", sync_losses
),
159 ("PrimitSeqErrors", "prim_seq_proto_errors", prim_seq_proto_errors
),
160 ("Invalid TX Words", "invalid_tx_words", invalid_tx_words
),
161 ("Invalid CRCs", "invalid_crcs", invalid_crcs
),
162 ("Address ID Errors", "address_id_errors", address_id_errors
),
163 ("Link Resets In", "link_reset_ins", link_reset_ins
),
164 ("Link Resets Out", "link_reset_outs", link_reset_outs
),
165 ("Offline Sequences In", "ols_ins", ols_ins
),
166 ("Offline Sequences Out", "ols_outs", ols_outs
),
167 ("Discards", "discards", discards
),
168 ("F_BSY frames", "c2_fbsy_frames", c2_fbsy_frames
),
169 ("F_RJT frames", "c2_frjt_frames", c2_frjt_frames
),
172 per_sec
= get_rate("qlogic_fcport.%s.%s" % (counter
, port_id
), this_time
, value
)
173 perfdata
.append((counter
, per_sec
))
177 message
+= ", %s: %s/s" % (descr
, per_sec
)
179 message
+= ", no protocol errors"
181 return status
, message
, perfdata
183 return 3, "Port %s not found" % item
186 check_info
["qlogic_fcport"] = {
187 'check_function': check_qlogic_fcport
,
188 'inventory_function': inventory_qlogic_fcport
,
189 'service_description': 'FC Port %s',
190 'has_perfdata': True,
191 'snmp_info': ( ".1.3.6.1.2.1.75.1",[
192 OID_END
, # Index of the Port
193 "2.1.1.3", # fcFxPortOperMode
194 "2.2.1.1", # fcFxPortPhysAdminStatus
195 "2.2.1.2", # fcFxPortPhysOperStatus
196 "3.1.1.1", # fcFxPortLinkFailures
197 "3.1.1.2", # fcFxPortSyncLosses
198 "3.1.1.4", # fcFxPortPrimSeqProtoErrors
199 "3.1.1.5", # fcFxPortInvalidTxWords
200 "3.1.1.6", # fcFxPortInvalidCrcs
201 "3.1.1.8", # fcFxPortAddressIdErrors
202 "3.1.1.9", # fcFxPortLinkResetIns
203 "3.1.1.10", # fcFxPortLinkResetOuts
204 "3.1.1.11", # fcFxPortOlsIns
205 "3.1.1.12", # fcFxPortOlsOuts
206 "4.2.1.1", # fcFxPortC2InFrames
207 "4.2.1.2", # fcFxPortC2OutFrames
208 "4.2.1.3", # fcFxPortC2InOctets
209 "4.2.1.4", # fcFxPortC2OutOctets
210 "4.2.1.5", # fcFxPortC2Discards
211 "4.2.1.6", # fcFxPortC2FbsyFrames
212 "4.2.1.7", # fcFxPortC2FrjtFrames
213 "4.3.1.1", # fcFxPortC3InFrames
214 "4.3.1.2", # fcFxPortC3OutFrames
215 "4.3.1.3", # fcFxPortC3InOctets
216 "4.3.1.4", # fcFxPortC3OutOctets
217 "4.3.1.5", # fcFxPortC3Discards
219 # .1.3.6.1.4.1.3873.1.14 Qlogic-Switch
220 # .1.3.6.1.4.1.3873.1.8 Qlogic-4Gb SAN Switch Module for IBM BladeCenter
221 # .1.3.6.1.4.1.3873.1.12 QLogic 8 Gb and 4/8 Gb Intelligent Pass-thru Module
222 # .1.3.6.1.4.1.3873.1.9 QLogic SANBox 5802 FC Switch
223 # .1.3.6.1.4.1.3873.1.11 HP StorageWorks 8/20q Fibre Channel Switch
224 'snmp_scan_function' : lambda oid
: \
225 oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.3873.1.14") \
226 or oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.3873.1.8") \
227 or oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.3873.1.11") \
228 or oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.3873.1.12") \
229 or oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.3873.1.9"),
230 'group': 'qlogic_fcport',
231 'default_levels_variable': 'qlogic_fcport_default_levels',