Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / mcdata_fcport
blobad2edb1eb83acc55a1042b17696be305417b59b4
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 mcdata_fcport_speedbits = {"2": '1000000000', "3": '2000000000'}
28 mcdata_fcport_opstatus = {"1": "1", "2": "2", "3": "testing", "4": "faulty"}
31 def mcdata_bin_to_64(bin_):
32 return str(binstring_to_int(bin_))
35 def mcdata_fcport_convert_to_if64(info):
36 return map(mcdata_fcport_convert_line_to_if64, info)
39 def mcdata_fcport_convert_line_to_if64(line):
40 index, opStatus, speed, txWords64, rxWords64, txFrames64, rxFrames64, c3Discards64, crcs = line
42 speed = mcdata_fcport_speedbits.get(speed, '')
43 opStatus = mcdata_fcport_opstatus.get(opStatus, 'unknown')
44 index = "%02d" % int(index)
46 return [
47 index, # 0 ifIndex
48 index, # 1 ifDescr
49 '6', # 2 ifType
50 speed, # 3 ifSpeed
51 opStatus, # 4 ifOperStatus
52 mcdata_bin_to_64(rxWords64) * 4, # 5 ifHCInOctets
53 mcdata_bin_to_64(rxFrames64), # 6 ifHCInUcastPkts
54 '0', # 7 ifHCInMulticastPkts
55 '0', # 8 ifHCInBroadcastPkts
56 '0', # 9 ifInDiscards
57 crcs, # 10 ifInErrors
58 mcdata_bin_to_64(txWords64) * 4, # 11 ifHCOutOctets
59 mcdata_bin_to_64(txFrames64), # 12 ifHCOutUcastPkts
60 '0', # 13 ifHCOutMulticastPkts
61 '0', # 14 ifHCOutBroadcastPkts
62 mcdata_bin_to_64(c3Discards64), # 15 ifOutDiscards
63 '0', # 16 ifOutErrors
64 '0', # 17 ifOutQLen
65 index, # 18 ifAlias
66 '', # 19 ifPhysAddress
70 def inventory_mcdata_fcport(info):
71 return inventory_if_common(mcdata_fcport_convert_to_if64(info))
74 def check_mcdata_fcport(item, params, info):
75 return check_if_common(item, params, mcdata_fcport_convert_to_if64(info))
78 check_includes['mcdata_fcport'] = ["if.include"]
79 check_info["mcdata_fcport"] = {
80 'check_function': check_mcdata_fcport,
81 'inventory_function': inventory_mcdata_fcport,
82 'service_description': 'Port %s',
83 'has_perfdata': True,
84 'snmp_info': (
85 '.1.3.6.1.4.1.289.2.1.1.2.3.1.1',
87 1, # EF-6000-MIB::ef6000PortIndex
88 3, # EF-6000-MIB::ef6000PortOpStatus
89 11, # EF-6000-MIB::ef6000PortSpeed
90 67, # EF-6000-MIB::ef6000PortTxWords64
91 68, # EF-6000-MIB::ef6000PortRxWords64
92 69, # EF-6000-MIB::ef6000PortTxFrames64
93 70, # EF-6000-MIB::ef6000PortRxFrames64
94 83, # EF-6000-MIB::ef6000PortC3Discards64
95 65, # EF-6000-MIB::ef6000PortCrcs
96 ]),
97 # check if number of network interfaces (IF-MIB::ifNumber.0) is at least 2
98 'snmp_scan_function': lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.289."),
99 'default_levels_variable': 'if_default_levels',