Collection of CheckMK checks (see https://checkmk.com/). All checks and plugins are provided as is. Absolutely no warranty. Send any comments to thl-cmk[at]outlook[dot]com

Skip to content
Snippets Groups Projects
Commit e13f7e96 authored by thl-cmk's avatar thl-cmk :flag_na:
Browse files

Delete ospfv3_virtuallink

parent 94cc93cc
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
#
#
# OSPFv3 virtual-link status
#
# Author: Th.L.
# Date : 2019-01-11
#
# Monitor status of OSPFv3 virtual-links
#
# .1.3.6.1.2.1.191.1.11.1.3.3.50529054 = INTEGER: 0
# .1.3.6.1.2.1.191.1.11.1.4.3.50529054 = Gauge32: 0
# .1.3.6.1.2.1.191.1.11.1.5.3.50529054 = INTEGER: 2
# .1.3.6.1.2.1.191.1.11.1.6.3.50529054 = Hex-STRING: 30 00 00 00 00 00 00 00 00 03 00 03 00 03 00 30
# .1.3.6.1.2.1.191.1.11.1.7.3.50529054 = INTEGER: 51
# .1.3.6.1.2.1.191.1.11.1.8.3.50529054 = INTEGER: 8
# .1.3.6.1.2.1.191.1.11.1.9.3.50529054 = Counter32: 6
# .1.3.6.1.2.1.191.1.11.1.10.3.50529054 = Gauge32: 1
# .1.3.6.1.2.1.191.1.11.1.11.3.50529054 = INTEGER: 1
# .1.3.6.1.2.1.191.1.11.1.12.3.50529054 = INTEGER: 26
# .1.3.6.1.2.1.191.1.11.1.13.3.50529054 = INTEGER: 1
# .1.3.6.1.2.1.191.1.11.1.14.3.50529054 = Gauge32: 0
# .1.3.6.1.2.1.191.1.11.1.15.3.50529054 = INTEGER: 1
#
# OSPFV3-MIB::ospfv3VirtNbrIfIndex.3.50529054 = INTEGER: 0
# OSPFV3-MIB::ospfv3VirtNbrIfInstId.3.50529054 = Gauge32: 0
# OSPFV3-MIB::ospfv3VirtNbrAddressType.3.50529054 = INTEGER: ipv6(2)
# OSPFV3-MIB::ospfv3VirtNbrAddress.3.50529054 = Hex-STRING: 30 00 00 00 00 00 00 00 00 03 00 03 00 03 00 30
# OSPFV3-MIB::ospfv3VirtNbrOptions.3.50529054 = INTEGER: 51
# OSPFV3-MIB::ospfv3VirtNbrState.3.50529054 = INTEGER: full(8)
# OSPFV3-MIB::ospfv3VirtNbrEvents.3.50529054 = Counter32: 6
# OSPFV3-MIB::ospfv3VirtNbrLsRetransQLen.3.50529054 = Gauge32: 0
# OSPFV3-MIB::ospfv3VirtNbrHelloSuppressed.3.50529054 = INTEGER: true(1)
# OSPFV3-MIB::ospfv3VirtNbrIfId.3.50529054 = INTEGER: 26
# OSPFV3-MIB::ospfv3VirtNbrRestartHelperStatus.3.50529054 = INTEGER: notHelping(1)
# OSPFV3-MIB::ospfv3VirtNbrRestartHelperAge.3.50529054 = Gauge32: 0 seconds
# OSPFV3-MIB::ospfv3VirtNbrRestartHelperExitReason.3.50529054 = INTEGER: none(1)
#
#
# [
# [
# [u'3.50529054', u'0', u'0', u'2', u'0\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x03\x00\x03\x000', u'51', u'8', u'6', u'0', u'1', u'26', u'1', u'0', u'1']
# ],
# [
# [u'1', u'Vlan1'],
# [u'5001', u'Port-channel1'],
# [u'10101', u'GigabitEthernet0/1'],
# [u'10102', u'GigabitEthernet0/2'],
# [u'10103', u'GigabitEthernet0/3'],
# [u'10104', u'GigabitEthernet0/4'],
# [u'10105', u'GigabitEthernet0/5'],
# [u'10106', u'GigabitEthernet0/6'],
# [u'10107', u'GigabitEthernet0/7'],
# [u'10108', u'GigabitEthernet0/8'],
# [u'10109', u'GigabitEthernet0/9'],
# [u'10110', u'GigabitEthernet0/10'],
# [u'10501', u'Null0'],
# [u'20567', u'Loopback0'],
# [u'20569', u'Loopback10'],
# [u'20570', u'Loopback20'],
# [u'20571', u'Loopback30']
# ]
# ]
#
factory_settings['ospfv3_virtuallink_default_levels'] = {
'ok_states' : [8, 4],
'warning_states' : [2, 3, 5, 6, 7],
'critical_states': [1],
}
###########################################################################
#
# DATA Parser function
#
###########################################################################
def parse_ospfv3_virtuallink(info):
def ospf_nbr_addresstype(st):
names = { '0': 'unknown',
'1': 'ipv4',
'2': 'ipv6',
'3': 'ipv4z',
'4': 'ipv6z',
'16':'dns',}
return names.get(st, st)
def ospf_nbr_hellosuppressed(st):
names = {'1': 'true',
'2': 'false'}
return names.get(st, st)
def ospf_nbr_helperstatus(st):
names = {'1': 'not Helping',
'2': 'helping'}
return names.get(st, st)
def ospf_nbr_helperexitreason(st):
names = {'1': 'none',
'2': 'inProgress',
'3': 'completed',
'4': 'timedOut',
'5': 'topologyChanged'}
return names.get(st, st)
def shorten_ipv6_adress(address):
address = address.split(':')
span = 2
address = [''.join(address[i:i + span]) for i in range(0, len(address), span)]
for m in range(0, len(address)):
address[m] = re.sub(r'^0{1,3}', r'', address[m])
address = ':'.join(address)
zeros = ':0:0:0:0:0:0:'
while not zeros == '':
if zeros in address:
address = re.sub(r'%s' % zeros, r'::', address)
zeros = ''
else:
zeros = zeros[:-2]
if address == '0::0':
address = '::'
return address
def render_ipv6_address(bytestring):
address = ":".join(["%02s" % hex(ord(m))[2:] for m in bytestring]).replace(' ', '0').upper()
address = shorten_ipv6_adress(address)
return address
def render_ipv4_neighbor_id(nbrRtrId):
nbrRtrId = int(nbrRtrId)
firstoctet = nbrRtrId / (256*256*256)
nbrRtrId = nbrRtrId - (firstoctet *256*256*256)
secondocted = nbrRtrId / (256*256)
nbrRtrId = nbrRtrId - (secondocted * 256 * 256)
thirdorted = nbrRtrId / 256
nbrRtrId = nbrRtrId - (thirdorted * 256)
nbrRtrId = '%d.%d.%d.%d' % (firstoctet, secondocted, thirdorted, nbrRtrId)
return nbrRtrId
def get_short_if_name(st):
names = {'ethernet': 'Eth',
'fastethernet': 'Fa',
'gigabitethernet': 'Gi',
'tengigabitethernet': 'Te',
'fortygigabitethernet': 'Fo',
'hundredgigabitethernet': 'Hu',
'port-channel': 'Po',
'tunnel': 'Tu',
'loopback': 'Lo',
}
for item in names.keys():
if st.lower().startswith(item):
st = st.lower().replace(item, names.get(item))
return st
virtual_links = []
virtual_links_info, interfaces = info
for virtual_link in virtual_links_info:
OID_END, VirtNbrIfIndex, VirtNbrIfInstId, VirtNbrAddressType, VirtNbrAddress, VirtNbrOptions, VirtNbrState, \
VirtNbrEvents, VirtNbrLsRetransQLen, VirtNbrHelloSuppressed, VirtNbrIfId, VirtNbrRestartHelperStatus, \
VirtNbrRestartHelperAge, VirtNbrRestartHelperExitReason, = virtual_link
if VirtNbrAddressType == '2': # IPv6 address
VirtNbrAddress = render_ipv6_address(VirtNbrAddress)
VirtNbrArea, VirtNbrId = OID_END.split('.')
nbrLocalInterface = ''
for interface in interfaces:
ifIndex, ifName = interface
if ifIndex == VirtNbrIfIndex:
nbrLocalInterface = get_short_if_name(ifName)
virtual_links.append({
'VirtNbrId': render_ipv4_neighbor_id(VirtNbrId),
'VirtNbrArea': int(VirtNbrArea),
'VirtNbrOptions': VirtNbrOptions,
'VirtNbrState': int(VirtNbrState),
'VirtNbrEvents': int(VirtNbrEvents),
'VirtNbrLsRetransQLen': int(VirtNbrLsRetransQLen),
'VirtNbrHelloSuppressed': ospf_nbr_hellosuppressed(VirtNbrHelloSuppressed),
'VirtNbrRestartHelperStatus': ospf_nbr_helperstatus(VirtNbrRestartHelperStatus),
'VirtNbrRestartHelperAge': int(VirtNbrRestartHelperAge),
'VirtNbrRestartHelperExitReason': ospf_nbr_helperexitreason(VirtNbrRestartHelperExitReason),
# 'itemtext': '%s on %s' % (VirtNbrAddress, nbrLocalInterface),
'itemtext': '%s' % VirtNbrAddress,
})
return virtual_links
###########################################################################
#
# INVENTORY function
#
###########################################################################
def inventory_ospfv3_virtuallink(parsed):
inventory = []
for virtual_link in parsed:
inventory.append((virtual_link.get('itemtext'), {}))
return inventory
###########################################################################
#
# CHECK function
#
###########################################################################
def check_ospfv3_virtuallink(item, params, parsed):
def ospf_nbr_state(st):
names = {1: 'down',
2: 'attempt',
3: 'init',
4: 'twoWay',
5: 'exchangeStart',
6: 'exchange',
7: 'loading',
8: 'full'}
return names.get(st, st)
for virtual_link in parsed:
if virtual_link.get('itemtext') == item:
infotext = ''
perfdata = []
longoutput = ''
nbrstatus = ospf_nbr_state(virtual_link.get('VirtNbrState'))
infotext += 'Neighbor ID: %s' % virtual_link.get('VirtNbrId')
infotext += ', Area: %s' % virtual_link.get('VirtNbrArea')
nbrstate = virtual_link.get('VirtNbrState')
if nbrstate in params['critical_states']:
yield 2, 'State: %s' % nbrstatus
elif nbrstate in params['warning_states']:
yield 1, 'State: %s' % nbrstatus
elif nbrstate in params['ok_states']:
infotext += ', State: %s' % nbrstatus
else:
yield 3, 'Invalid Output from Agent'
perfdata.append(['ospf_events', virtual_link.get('VirtNbrEvents')])
perfdata.append(['ospf_lsretransqlen', virtual_link.get('VirtNbrLsRetransQLen')])
longoutput += '\nVirtual link options: %s' % virtual_link.get('VirtNbrOptions')
longoutput += '\nVirtual link hello suppressed: %s' % virtual_link.get('VirtNbrHelloSuppressed')
longoutput += '\nVirtual link helper status: %s' % virtual_link.get('VirtNbrRestartHelperStatus')
longoutput += '\nVirtual link helper age: %s' % virtual_link.get('VirtNbrRestartHelperAge')
longoutput += '\nVirtual link helper exit reason: %s' % virtual_link.get('VirtNbrRestartHelperExitReason')
yield 0, infotext + longoutput, perfdata
###########################################################################
#
# CHECK info
#
###########################################################################
check_info['ospfv3_virtuallink'] = {
'check_function' : check_ospfv3_virtuallink,
'inventory_function' : inventory_ospfv3_virtuallink,
'service_description' : 'OSPFv3 virtual-link %s',
'default_levels_variable': 'ospfv3_virtuallink_default_levels',
'parse_function' : parse_ospfv3_virtuallink,
'has_perfdata' : True,
'snmp_scan_function' : lambda oid: oid('.1.3.6.1.2.1.191.1.11.1.3.*') != None, # OSPFV3-MIB::ospfv3IfAreaId
'snmp_info' : [('.1.3.6.1.2.1.191.1.11.1', [ # OSPFV3-MIB::ospfv3IfTable
OID_END, # ospfv3IfIndex, ospfv3IfInstId
'3', # ospfv3VirtNbrIfIndex
'4', # ospfv3VirtNbrIfInstId
'5', # ospfv3VirtNbrAddressType
'6', # ospfv3VirtNbrAddress
'7', # ospfv3VirtNbrOptions
'8', # ospfv3VirtNbrState
'9', # ospfv3VirtNbrEvents
'10', # ospfv3VirtNbrLsRetransQLen
'11', # ospfv3VirtNbrHelloSuppressed
'12', # ospfv3VirtNbrIfId
'13', # ospfv3VirtNbrRestartHelperStatus
'14', # ospfv3VirtNbrRestartHelperAge
'15', # ospfv3VirtNbrRestartHelperExitReason
]),
('.1.3.6.1.2.1.2.2.1', [
'1', # ifIndex
'2', # ifDescr
]),
],
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment