Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / if64.include
blob2c17192565ad4ad321c6a0ad526a56f5105e4fac
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 # Common code of i64 and if64adm
28 inventory_if_rules = []
31 def _convert_type(if_type):
32 try:
33 int(if_type)
34 except ValueError:
35 return str(if64_port_types.get(if_type, '1'))
36 else:
37 return if_type
40 def _convert_status(if_status):
41 try:
42 int(if_status)
43 except ValueError:
44 return str(if64_status_names.get(if_status, '4'))
45 else:
46 return if_status
49 def parse_if64(info):
50 parsed = []
51 for line in info:
52 # some DLINK switches apparently report a broken interface with index 0,
53 # filter that out
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])
60 else:
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])
68 return parsed
71 def need_if64adm():
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()):
78 return False
80 sys_descr = oid(".1.3.6.1.2.1.1.1.0")
81 for ignored_sys_descr in [
82 "LANCOM",
83 "ELSA",
84 "T-Systems",
85 "Brocade VDX Switch",
87 if ignored_sys_descr in sys_descr:
88 return False
90 sys_obj_id = oid(".1.3.6.1.2.1.1.2.0")
91 for ignored_sys_obj_id in [
92 ".4.1.11863.",
93 ".1.3.6.1.4.1.12356",
95 if ignored_sys_obj_id in sys_obj_id:
96 return False
98 if need_if64adm() != use_if64adm:
99 return False
101 if oid(".1.3.6.1.2.1.31.1.1.1.6.*") is not None:
102 return True
104 return False
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 = {
132 'up': '1',
133 'down': '2',
134 'testing': '3',
135 'unknown': '4',
136 'dormant': '5',
137 'not present': '6',
138 'lower layer down': '7',
139 'degraded': '8',
140 'admin down': '9',
143 if64_port_types = {
144 'other': '1',
145 'regular1822': '2',
146 'hdh1822': '3',
147 'ddnX25': '4',
148 'rfc877x25': '5',
149 'ethernetCsmacd': '6',
150 'iso88023Csmacd': '7',
151 'iso88024TokenBus': '8',
152 'iso88025TokenRing': '9',
153 'iso88026Man': '10',
154 'starLan': '11',
155 'proteon10Mbit': '12',
156 'proteon80Mbit': '13',
157 'hyperchannel': '14',
158 'fddi': '15',
159 'lapb': '16',
160 'sdlc': '17',
161 'ds1': '18',
162 'e1': '19',
163 'basicISDN': '20',
164 'primaryISDN': '21',
165 'propPointToPointSerial': '22',
166 'ppp': '23',
167 'softwareLoopback': '24',
168 'eon': '25',
169 'ethernet3Mbit': '26',
170 'nsip': '27',
171 'slip': '28',
172 'ultra': '29',
173 'ds3': '30',
174 'sip': '31',
175 'frameRelay': '32',
176 'rs232': '33',
177 'para': '34',
178 'arcnet': '35',
179 'arcnetPlus': '36',
180 'atm': '37',
181 'miox25': '38',
182 'sonet': '39',
183 'x25ple': '40',
184 'iso88022llc': '41',
185 'localTalk': '42',
186 'smdsDxi': '43',
187 'frameRelayService': '44',
188 'v35': '45',
189 'hssi': '46',
190 'hippi': '47',
191 'modem': '48',
192 'aal5': '49',
193 'sonetPath': '50',
194 'sonetVT': '51',
195 'smdsIcip': '52',
196 'propVirtual': '53',
197 'propMultiplexor': '54',
198 'ieee80212': '55',
199 'fibreChannel': '56',
200 'hippiInterface': '57',
201 'frameRelayInterconnect': '58',
202 'aflane8023': '59',
203 'aflane8025': '60',
204 'cctEmul': '61',
205 'fastEther': '62',
206 'isdn': '63',
207 'v11': '64',
208 'v36': '65',
209 'g703at64k': '66',
210 'g703at2mb': '67',
211 'qllc': '68',
212 'fastEtherFX': '69',
213 'channel': '70',
214 'ieee80211': '71',
215 'ibm370parChan': '72',
216 'escon': '73',
217 'dlsw': '74',
218 'isdns': '75',
219 'isdnu': '76',
220 'lapd': '77',
221 'ipSwitch': '78',
222 'rsrb': '79',
223 'atmLogical': '80',
224 'ds0': '81',
225 'ds0Bundle': '82',
226 'bsc': '83',
227 'async': '84',
228 'cnr': '85',
229 'iso88025Dtr': '86',
230 'eplrs': '87',
231 'arap': '88',
232 'propCnls': '89',
233 'hostPad': '90',
234 'termPad': '91',
235 'frameRelayMPI': '92',
236 'x213': '93',
237 'adsl': '94',
238 'radsl': '95',
239 'sdsl': '96',
240 'vdsl': '97',
241 'iso88025CRFPInt': '98',
242 'myrinet': '99',
243 'voiceEM': '100',
244 'voiceFXO': '101',
245 'voiceFXS': '102',
246 'voiceEncap': '103',
247 'voiceOverIp': '104',
248 'atmDxi': '105',
249 'atmFuni': '106',
250 'atmIma': '107',
251 'pppMultilinkBundle': '108',
252 'ipOverCdlc': '109',
253 'ipOverClaw': '110',
254 'stackToStack': '111',
255 'virtualIpAddress': '112',
256 'mpc': '113',
257 'ipOverAtm': '114',
258 'iso88025Fiber': '115',
259 'tdlc': '116',
260 'gigabitEthernet': '117',
261 'hdlc': '118',
262 'lapf': '119',
263 'v37': '120',
264 'x25mlp': '121',
265 'x25huntGroup': '122',
266 'trasnpHdlc': '123',
267 'interleave': '124',
268 'fast': '125',
269 'ip': '126',
270 'docsCableMaclayer': '127',
271 'docsCableDownstream': '128',
272 'docsCableUpstream': '129',
273 'a12MppSwitch': '130',
274 'tunnel': '131',
275 'coffee': '132',
276 'ces': '133',
277 'atmSubInterface': '134',
278 'l2vlan': '135',
279 'l3ipvlan': '136',
280 'l3ipxvlan': '137',
281 'digitalPowerline': '138',
282 'mediaMailOverIp': '139',
283 'dtm': '140',
284 'dcn': '141',
285 'ipForward': '142',
286 'msdsl': '143',
287 'ieee1394': '144',
288 'if-gsn': '145',
289 'dvbRccMacLayer': '146',
290 'dvbRccDownstream': '147',
291 'dvbRccUpstream': '148',
292 'atmVirtual': '149',
293 'mplsTunnel': '150',
294 'srp': '151',
295 'voiceOverAtm': '152',
296 'voiceOverFrameRelay': '153',
297 'idsl': '154',
298 'compositeLink': '155',
299 'ss7SigLink': '156',
300 'propWirelessP2P': '157',
301 'frForward': '158',
302 'rfc1483': '159',
303 'usb': '160',
304 'ieee8023adLag': '161',
305 'bgppolicyaccounting': '162',
306 'frf16MfrBundle': '163',
307 'h323Gatekeeper': '164',
308 'h323Proxy': '165',
309 'mpls': '166',
310 'mfSigLink': '167',
311 'hdsl2': '168',
312 'shdsl': '169',
313 'ds1FDL': '170',
314 'pos': '171',
315 'dvbAsiIn': '172',
316 'dvbAsiOut': '173',
317 'plc': '174',
318 'nfas': '175',
319 'tr008': '176',
320 'gr303RDT': '177',
321 'gr303IDT': '178',
322 'isup': '179',
323 'propDocsWirelessMaclayer': '180',
324 'propDocsWirelessDownstream': '181',
325 'propDocsWirelessUpstream': '182',
326 'hiperlan2': '183',
327 'propBWAp2Mp': '184',
328 'sonetOverheadChannel': '185',
329 'digitalWrapperOverheadChannel': '186',
330 'aal2': '187',
331 'radioMAC': '188',
332 'atmRadio': '189',
333 'imt': '190',
334 'mvl': '191',
335 'reachDSL': '192',
336 'frDlciEndPt': '193',
337 'atmVciEndPt': '194',
338 'opticalChannel': '195',
339 'opticalTransport': '196',
340 'propAtm': '197',
341 'voiceOverCable': '198',
342 'infiniband': '199',
343 'teLink': '200',
344 'q2931': '201',
345 'virtualTg': '202',
346 'sipTg': '203',
347 'sipSig': '204',
348 'docsCableUpstreamChannel': '205',
349 'econet': '206',
350 'pon155': '207',
351 'pon622': '208',
352 'bridge': '209',
353 'linegroup': '210',
354 'voiceEMFGD': '211',
355 'voiceFGDEANA': '212',
356 'voiceDID': '213',
357 'mpegTransport': '214',
358 'sixToFour': '215',
359 'gtp': '216',
360 'pdnEtherLoop1': '217',
361 'pdnEtherLoop2': '218',
362 'opticalChannelGroup': '219',
363 'homepna': '220',
364 'gfp': '221',
365 'ciscoISLvlan': '222',
366 'actelisMetaLOOP': '223',
367 'fcipLink': '224',
368 'rpr': '225',
369 'qam': '226',
370 'lmp': '227',
371 'cblVectaStar': '228',
372 'docsCableMCmtsDownstream': '229',
373 'adsl2': '230',