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 410fea15 authored by thl-cmk's avatar thl-cmk :flag_na:
Browse files

update project

parent fce4bc65
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,7 @@
#
# Cisco BGP Peer
#
# Author: Th.L.
# Author: thl-cmk[at]outlook[dot]com / thl-cmk.hopto.org
# Date : 2017-12-26
#
# Monitor status of Cisco BGP Peer (IPv4 and IPv6)
......@@ -20,6 +20,7 @@
# 02.18.2019: added fix for empty values ("" instead of "0") sugested by Laurent Barbier (lbarbier[at]arkane-studios[dot]com)
# 24.02.2020: added workaround for missing cbgpPeer2AddrFamily (example L2VPN EVPN peers, Fix for jonale82[at]gmail[dot]com)
# 02.03.2020: changed handling of perfdata, add only data the are really there (not None, instead of setting them to 0)
# 04.06.2020: code cleanup --> changed isdigit test to try/except loop, changed peer.get test to try/except loop
#
#
......@@ -277,33 +278,25 @@ def parse_cisco_bgp_peer(info):
prefixclearthreshold, advertisedprefixes, suppressedprefixes, withdrawnprefixes = entry
remoteaddr = cisco_bgp_get_peer(entry[0])
peer = {'remoteaddr': remoteaddr}
peer.update({'addrfamilyname': addrfamilyname})
if prefixadminlimit.isdigit():
peer.update({'prefixadminlimit':int(prefixadminlimit)})
if prefixthreshold.isdigit():
peer.update({'prefixthreshold':int(prefixthreshold)})
if prefixclearthreshold.isdigit():
peer.update({'prefixclearthreshold':int(prefixclearthreshold)})
if acceptedprefixes.isdigit():
peer.update({'acceptedprefixes':int(acceptedprefixes)})
if advertisedprefixes.isdigit():
peer.update({'advertisedprefixes':int(advertisedprefixes)})
if deniedprefixes.isdigit():
peer.update({'deniedprefixes':int(deniedprefixes)})
if suppressedprefixes.isdigit():
peer.update({'suppressedprefixes':int(suppressedprefixes)})
if withdrawnprefixes.isdigit():
peer.update({'withdrawnprefixes':int(withdrawnprefixes)})
peer = {
'remoteaddr': remoteaddr,
'addrfamilyname': addrfamilyname
}
for key, value in [
('prefixadminlimit', prefixadminlimit),
('prefixthreshold', prefixthreshold),
('prefixclearthreshold', prefixclearthreshold),
('acceptedprefixes', acceptedprefixes),
('advertisedprefixes', advertisedprefixes),
('deniedprefixes', deniedprefixes),
('suppressedprefixes', suppressedprefixes),
('withdrawnprefixes', withdrawnprefixes),
]:
try:
peer[key] = int(value)
except ValueError:
pass
peer_prefixes.update({'%s %s' % (remoteaddr, addrfamilyname): peer})
......@@ -313,8 +306,7 @@ def parse_cisco_bgp_peer(info):
remoteaddr = cisco_bgp_get_peer(entry[0])
addrfamilyname = ''
peer = {'remoteaddr': remoteaddr,
}
peer = {'remoteaddr': remoteaddr,}
peer_prefixes.update({'%s %s' % (remoteaddr, addrfamilyname): peer})
......@@ -335,26 +327,22 @@ def parse_cisco_bgp_peer(info):
'prevstate': int(prevstate),
}
if state.isdigit():
peer.update({'state': int(state)})
if adminstatus.isdigit():
peer.update({'adminstate': int(adminstatus)})
if localas.isdigit():
peer.update({'localas': int(localas)})
if remoteas.isdigit():
peer.update({'remoteas': int(remoteas)})
if inupdates.isdigit():
peer.update({'inupdates':int(inupdates)})
if outupdates.isdigit():
peer.update({'outupdates': int(outupdates)})
if intotalmessages.isdigit():
peer.update({'intotalmessages': int(intotalmessages)})
if outtotalmessages.isdigit():
peer.update({'outtotalmessages': int(outtotalmessages)})
if fsmestablishedtransitions.isdigit():
peer.update({'fsmestablishedtransitions': int(fsmestablishedtransitions)})
if inupdates.isdigit():
peer.update({'fsmestablishedtime': int(fsmestablishedtime)})
for key, value in [
('state', state),
('adminstate', adminstatus),
('localas', localas),
('remoteas', remoteas),
('inupdates', inupdates),
('outupdates', outupdates),
('intotalmessages', intotalmessages),
('outtotalmessages', outtotalmessages),
('fsmestablishedtransitions', fsmestablishedtransitions),
('fsmestablishedtime', fsmestablishedtime),
]:
try:
peer[key] = int(value)
except ValueError:
pass
peer_table.update({'%s' % cisco_bgp_get_peer(oid_end): peer})
......@@ -437,20 +425,23 @@ def check_cisco_bgp_peer(item, params, parsed):
if peer.get('localas') == 0:
peer.update({'localas': params.get('useaslocalas')})
infotext_values = params.get('infotext_values')
infotext_values = params.get('infotext_values', [])
if alias != '':
infotext += ', Alias: %s' % alias
if 'remoteid' in infotext_values:
infotext += ', Remote ID: %s' % peer.get('remoteid')
if 'remoteas' in infotext_values:
infotext += ', Remote AS: %s' % peer.get('remoteas')
if 'localaddr' in infotext_values:
infotext += ', Local address: %s' % peer.get('localaddr')
if 'localid' in infotext_values:
infotext += ', Local ID: %s' % peer.get('localid')
if 'localas' in infotext_values:
infotext += ', Local AS: %s' % peer.get('localas')
for key, value in [
('remoteid', ', Remote ID: %s'),
('remoteas', ', Remote AS: %s'),
('localaddr', ', Local address: %s'),
('localid', ', Local ID: %s'),
('localas', ', Local AS: %s'),
]:
try:
if key not in infotext_values:
infotext += value % peer[key]
except KeyError:
pass
peerstate = peer.get('state')
adminstate = peer.get('adminstate')
......@@ -520,7 +511,7 @@ def check_cisco_bgp_peer(item, params, parsed):
else:
longoutput += '\n{}: {}'.format(entry[0], entry[1])
if prefixadminlimit is not None and acceptedprefixes is not None and prefixadminlimit is not None and warnthreshold is not None:
if prefixadminlimit is not None and acceptedprefixes is not None and warnthreshold is not None:
if acceptedprefixes >= prefixadminlimit:
yield 2, 'Prefix admin limit reached (%d/%d)' % (acceptedprefixes, prefixadminlimit)
elif prefixthreshold > 0:
......@@ -533,39 +524,33 @@ def check_cisco_bgp_peer(item, params, parsed):
perfdata.append(('acceptedprefixes', acceptedprefixes))
now_time = time.time()
rate_item = item.replace(' ', '_')
if prefixes.get('deniedprefixes', None) is not None:
deniedprefixes = get_rate('cisco_bgp_peer.%s.%s' % ('deniedprefixes', rate_item), now_time, prefixes.get('deniedprefixes', 0), onwrap=SKIP)
perfdata.append(('deniedprefixes', deniedprefixes))
if prefixes.get('advertisedprefixes', None) is not None:
advertisedprefixes = get_rate('cisco_bgp_peer.%s.%s' % ('advertisedprefixes', rate_item), now_time, prefixes.get('advertisedprefixes', 0), onwrap=SKIP)
perfdata.append(('advertisedprefixes', advertisedprefixes))
if prefixes.get('withdrawnprefixes', None) is not None:
withdrawnprefixes = get_rate('cisco_bgp_peer.%s.%s' % ('withdrawnprefixes', rate_item), now_time, prefixes.get('withdrawnprefixes', 0), onwrap=SKIP)
perfdata.append(('withdrawnprefixes', withdrawnprefixes))
if prefixes.get('suppressedprefixes', None) is not None:
suppressedprefixes = get_rate('cisco_bgp_peer.%s.%s' % ('suppressedprefixes', rate_item), now_time, prefixes.get('suppressedprefixes', 0), onwrap=SKIP)
perfdata.append(('suppressedprefixes', suppressedprefixes))
if peer.get('inupdates', None) is not None:
inupdates = get_rate('cisco_bgp_peer.%s.%s' % ('inupdates', rate_item), now_time, peer.get('inupdates', 0), onwrap=SKIP)
perfdata.append(('inupdates', inupdates))
if peer.get('outupdates', None) is not None:
outupdates = get_rate('cisco_bgp_peer.%s.%s' % ('outupdates', rate_item), now_time, peer.get('outupdates', 0), onwrap=SKIP)
perfdata.append(('outupdates', outupdates))
if peer.get('intotalmessages', None) is not None:
intotalmessages = get_rate('cisco_bgp_peer.%s.%s' % ('intotalmessages', rate_item), now_time, peer.get('intotalmessages', 0), onwrap=SKIP)
perfdata.append(('intotalmessages', intotalmessages))
if peer.get('outtotalmessages', None) is not None:
outtotalmessages = get_rate('cisco_bgp_peer.%s.%s' % ('outtotalmessages', rate_item), now_time, peer.get('outtotalmessages', 0), onwrap=SKIP)
perfdata.append(('outtotalmessages', outtotalmessages))
if peer.get('fsmestablishedtransitions', None) is not None:
perfdata.append(('fsmestablishedtransitions', peer.get('fsmestablishedtransitions')))
if peer.get('fsmestablishedtime', None) is not None:
perfdata.append(('fsmestablishedtime', peer.get('fsmestablishedtime')))
if peer.get('inupdateelapsedtime', None) is not None:
perfdata.append(('inupdateelapsedtime', peer.get('inupdateelapsedtime')))
rate_item = item.replace(' ', '_').replace(':','_')
for key in [
'deniedprefixes',
'advertisedprefixes',
'withdrawnprefixes',
'suppressedprefixes',
'inupdates',
'outupdates',
'intotalmessages',
'outtotalmessages',
]:
try:
value = get_rate('cisco_bgp_peer.%s.%s' % (key, rate_item), now_time, prefixes[key], onwrap=SKIP)
perfdata.append((key, value))
except KeyError:
pass
for key in [
'fsmestablishedtransitions',
'fsmestablishedtime',
'inupdateelapsedtime'
]:
try:
perfdata.append((key, peer[key]))
except KeyError:
pass
if infotext[0:2] == ', ':
infotext = infotext[2:]
......
No preview for this file type
......@@ -7,6 +7,6 @@
'name': 'cisco_bgp_peer',
'num_files': 3,
'title': u'Cisco BGP Peer',
'version': '20200302.v.0.2d',
'version': '20200604.v.0.2c',
'version.min_required': '1.2.8b8',
'version.packaged': '1.4.0p38'}
\ No newline at end of file
......@@ -4,7 +4,7 @@
#
# Check_MK cisco_bgp_peers WATO plugin
#
# Author: Th.L.
# Author: thl-cmk[at]outlook[dot]com / thl-cmk.hopto.org
# Date: 2017-12-25
#
#
......@@ -12,7 +12,7 @@
#
infotext_values = [
cisco_bgp_peer_infotext_values = [
('remoteid', 'Remote router ID'),
('remoteas', 'Remote autonomous system'),
('localaddr', 'Local peer IP address'),
......@@ -56,10 +56,10 @@ register_check_parameters(
)),
('infotext_values',
ListChoice(
title=_('Infotext values'),
label=_('Infotext values'),
help=_('Values to show in Infotext'),
choices=infotext_values,
title=_('Remove values from Infotext'),
label=_('Remove values from infotext'),
help=_('Select values to remove from check output.'),
choices=cisco_bgp_peer_infotext_values,
default_value=[],
)),
('peer_list',
......@@ -68,7 +68,7 @@ register_check_parameters(
title=('BGP Peers'),
elements=[
TextUnicode(
title=_('BGP Peer item name'),
title=_('BGP Peer item name (without "Cisco BGP peer")'),
help=_('The configured value must match a BGP item reported by the monitored '
'device. For example: "10.194.115.98 IPv4 Unicast"'),
allow_empty=False,
......
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