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 # Common code of i64 and if64adm
28 inventory_if_rules
= []
31 def _convert_type(if_type
):
35 return str(if64_port_types
.get(if_type
, '1'))
40 def _convert_status(if_status
):
44 return str(if64_status_names
.get(if_status
, '4'))
52 # some DLINK switches apparently report a broken interface with index 0,
54 if saveint(line
[1]) > 0:
55 # ifHighSpeed (idx 21) can't represent interfaces with less than 10^6 bit bandwidth,
56 # ifSpeed (idx 4) is capped at 4GBit.
57 # combine the two to get the actual interface speed
58 if line
[-1] in ["0", ""]:
59 real_speed
= saveint(line
[4])
61 real_speed
= saveint(line
[-1]) * 1000000
63 # Fujitsu SC2 Servers do not use numeric values for port state and type
64 if_type
= _convert_type(line
[3])
65 if_oper_status
= _convert_status(line
[5])
67 parsed
.append(line
[:3] + [if_type
, real_speed
, if_oper_status
] + line
[6:-1])
72 settings
= host_extra_conf_merged(host_name(), inventory_if_rules
)
73 return "portstates" in settings
and '9' in settings
["portstates"]
76 def if64_scan_function(oid
, use_if64adm
=False):
77 if if64_disabled(host_name()):
80 sys_descr
= oid(".1.3.6.1.2.1.1.1.0")
81 for ignored_sys_descr
in [
87 if ignored_sys_descr
in sys_descr
:
90 sys_obj_id
= oid(".1.3.6.1.2.1.1.2.0")
91 for ignored_sys_obj_id
in [
95 if ignored_sys_obj_id
in sys_obj_id
:
98 if need_if64adm() != use_if64adm
:
101 if oid(".1.3.6.1.2.1.31.1.1.1.6.*") is not None:
107 if64_snmp_end_oids
= [
108 "2.2.1.1", # ifIndex 0
109 "2.2.1.2", # ifDescr 1
110 "2.2.1.3", # ifType 2
111 "2.2.1.5", # ifSpeed 3
112 "2.2.1.8", # ifOperStatus 4
113 "31.1.1.1.6", # ifHCInOctets 5
114 "31.1.1.1.7", # ifHCInUcastPkts 6
115 "31.1.1.1.8", # ifHCInMulticastPkts 7
116 "31.1.1.1.9", # ifHCInBroadcastPkts 8
117 "2.2.1.13", # ifInDiscards 9
118 "2.2.1.14", # ifInErrors 10
119 "31.1.1.1.10", # ifHCOutOctets 11
120 "31.1.1.1.11", # ifHCOutUcastPkts 12
121 "31.1.1.1.12", # ifHCOutMulticastPkts 13
122 "31.1.1.1.13", # ifHCOutBroadcastPkts 14
123 "2.2.1.19", # ifOutDiscards 15
124 "2.2.1.20", # ifOutErrors 16
125 "2.2.1.21", # ifOutQLen 17
126 "31.1.1.1.18", # ifAlias 18
127 BINARY("2.2.1.6"), # ifPhysAddress 19
128 "31.1.1.1.15", # ifHighSpeed -1 (parse_if64 assumes this is the last element)
131 if64_status_names
= {
138 'lower layer down': '7',
149 'ethernetCsmacd': '6',
150 'iso88023Csmacd': '7',
151 'iso88024TokenBus': '8',
152 'iso88025TokenRing': '9',
155 'proteon10Mbit': '12',
156 'proteon80Mbit': '13',
157 'hyperchannel': '14',
165 'propPointToPointSerial': '22',
167 'softwareLoopback': '24',
169 'ethernet3Mbit': '26',
187 'frameRelayService': '44',
197 'propMultiplexor': '54',
199 'fibreChannel': '56',
200 'hippiInterface': '57',
201 'frameRelayInterconnect': '58',
215 'ibm370parChan': '72',
235 'frameRelayMPI': '92',
241 'iso88025CRFPInt': '98',
247 'voiceOverIp': '104',
251 'pppMultilinkBundle': '108',
254 'stackToStack': '111',
255 'virtualIpAddress': '112',
258 'iso88025Fiber': '115',
260 'gigabitEthernet': '117',
265 'x25huntGroup': '122',
270 'docsCableMaclayer': '127',
271 'docsCableDownstream': '128',
272 'docsCableUpstream': '129',
273 'a12MppSwitch': '130',
277 'atmSubInterface': '134',
281 'digitalPowerline': '138',
282 'mediaMailOverIp': '139',
289 'dvbRccMacLayer': '146',
290 'dvbRccDownstream': '147',
291 'dvbRccUpstream': '148',
295 'voiceOverAtm': '152',
296 'voiceOverFrameRelay': '153',
298 'compositeLink': '155',
300 'propWirelessP2P': '157',
304 'ieee8023adLag': '161',
305 'bgppolicyaccounting': '162',
306 'frf16MfrBundle': '163',
307 'h323Gatekeeper': '164',
323 'propDocsWirelessMaclayer': '180',
324 'propDocsWirelessDownstream': '181',
325 'propDocsWirelessUpstream': '182',
327 'propBWAp2Mp': '184',
328 'sonetOverheadChannel': '185',
329 'digitalWrapperOverheadChannel': '186',
336 'frDlciEndPt': '193',
337 'atmVciEndPt': '194',
338 'opticalChannel': '195',
339 'opticalTransport': '196',
341 'voiceOverCable': '198',
348 'docsCableUpstreamChannel': '205',
355 'voiceFGDEANA': '212',
357 'mpegTransport': '214',
360 'pdnEtherLoop1': '217',
361 'pdnEtherLoop2': '218',
362 'opticalChannelGroup': '219',
365 'ciscoISLvlan': '222',
366 'actelisMetaLOOP': '223',
371 'cblVectaStar': '228',
372 'docsCableMCmtsDownstream': '229',