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

update project

parent 34745af2
No related branches found
No related tags found
No related merge requests found
......@@ -52,6 +52,8 @@
# 2022-04-29: added info if device is admin prefix limit capable (device_admin_limit)
# 2022-04-30: code cleanup/streamlining
# 2022-05-09: added item to BgpPeer class, this is used in the discovery function
# 2022-05-11: changed bgp_get_peer_entry to get proper parameters instead of Nontransparent list
# added remote_as to BgpPeerItem
#
import copy
......@@ -83,6 +85,8 @@ from cmk.base.plugins.agent_based.utils.bgp_peer import (
# cisco_bgp_peer (CISCO-BGP4-MIB:cbgpPeer2Entry)
#
###########################################################################
@dataclass
class CiscoPrefixes:
address_family: str
......@@ -133,16 +137,30 @@ def parse_cisco_bgp_peer(string_table: List[StringTable]) -> Dict[str, BgpPeer]:
# create dictionary from cbgpPeer2Entry (peer ip address as index)
peer_table: Dict[str, BgpPeer] = {}
for entry in cbgpPeer2Entry:
remote_address = bgp_get_ip_address_from_oid(entry[0])
entry[0] = remote_address # replace OID_END with remote address
bgp_peer = bgp_get_peer_entry(entry)
remote_addr, peer_state, admin_state, remote_as, in_updates, out_updates, in_messages, out_messages, \
fsm_established_transitions, fsm_established_time, in_update_elapsed_time = entry
remote_addr = bgp_get_ip_address_from_oid(remote_addr)
bgp_peer = bgp_get_peer_entry(
remote_addr=remote_addr,
peer_state=peer_state,
admin_state=admin_state,
remote_as=remote_as,
in_updates=in_updates,
out_updates=out_updates,
in_messages=in_messages,
out_messages=out_messages,
fsm_established_transitions=fsm_established_transitions,
fsm_established_time=fsm_established_time,
in_update_elapsed_time=in_update_elapsed_time
)
if bgp_peer:
prefixes = peer_prefixes.get(remote_address, [])
prefixes = peer_prefixes.get(remote_addr, [])
if prefixes:
for address_family in prefixes:
item = f'{remote_address} {address_family.address_family}'
item = f'{remote_addr} {address_family.address_family}'
temp_bgp_peer = copy.deepcopy(bgp_peer)
peer_table[item] = temp_bgp_peer[remote_address]
peer_table[item] = temp_bgp_peer[remote_addr]
peer_table[item].accepted_prefixes = address_family.accepted_prefixes
peer_table[item].prefix_admin_limit = address_family.prefix_admin_limit
peer_table[item].prefix_clear_threshold = address_family.prefix_clear_threshold
......@@ -169,6 +187,7 @@ register.snmp_section(
OIDEnd(),
'3', # cbgpPeer2State
'4', # cbgpPeer2AdminStatus
'11', # cbgpPeer2RemoteAs
'13', # cbgpPeer2InUpdates
'14', # cbgpPeer2OutUpdates
'15', # cbgpPeer2InTotalMessages
......@@ -213,21 +232,33 @@ register.snmp_section(
def parse_cisco_bgp_peer_3(string_table: StringByteTable) -> Optional[Dict[str, BgpPeer]]:
peer_table = {}
for entry in string_table:
if entry[0] == '1': # IPv4 address
remote_address = '.'.join(f'{m}' for m in entry[1])
entry[1] = remote_address
remote_addr_type, remote_addr, routing_instance, peer_state, admin_state, remote_as, in_updates, out_updates, \
in_messages, out_messages, fsm_established_transitions, fsm_established_time, in_update_elapsed_time = entry
if remote_addr_type == '1': # IPv4 address
remote_addr = '.'.join(f'{m}' for m in remote_addr)
routing_instance = None
if entry[2] != 'default':
routing_instance = f'vrf {entry[2]}'
# entry[1] += f' {routing_instance}'
entry.pop(2) # remove vrf name
entry.pop(0) # remove remote address type
bgp_peer = bgp_get_peer_entry(entry)
if routing_instance != 'default':
routing_instance = f'vrf {routing_instance}'
bgp_peer = bgp_get_peer_entry(
remote_addr=remote_addr,
peer_state=peer_state,
admin_state=admin_state,
remote_as=remote_as,
in_updates=in_updates,
out_updates=out_updates,
in_messages=in_messages,
out_messages=out_messages,
fsm_established_transitions=fsm_established_transitions,
fsm_established_time=fsm_established_time,
in_update_elapsed_time=in_update_elapsed_time
)
if bgp_peer:
bgp_peer[remote_address].item['routing_instance'] = routing_instance
bgp_peer[remote_addr].item['routing_instance'] = routing_instance
if routing_instance:
item = f'{remote_address} {routing_instance}'
bgp_peer = {item: bgp_peer[remote_address]}
item = f'{remote_addr} {routing_instance}'
bgp_peer = {item: bgp_peer[remote_addr]}
peer_table.update(bgp_peer)
return peer_table
......@@ -245,6 +276,7 @@ register.snmp_section(
'4', # cbgpPeer3VrfName
'5', # cbgpPeer3State
'6', # cbgpPeer3AdminStatus
'13', # cbgpPeer3RemoteAs
'15', # cbgpPeer3InUpdates
'16', # cbgpPeer3OutUpdates
'17', # cbgpPeer3InTotalMessages
......
No preview for this file type
......@@ -26,7 +26,7 @@
'name': 'cisco_bgp_peer',
'num_files': 3,
'title': 'Cisco BGP Peer',
'version': '20220509.v.0.7',
'version': '20220511.v.0.8',
'version.min_required': '2.0.0',
'version.packaged': '2021.09.20',
'version.usable_until': None}
\ No newline at end of file
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