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

update project

parent b058dd72
No related branches found
No related tags found
No related merge requests found
......@@ -27,6 +27,7 @@
# moved helper functions to utils/bgp_peer
# 2021-11-14: merged check function with cisco_bgp_peer
# moved parse function to utils/bgp_peer
# 2021-04-02: rewritten bgp neighbor state handling (made configurable)
#
# ToDo: make check/discovery function the base for huawei_bgp_peer
......@@ -90,7 +91,18 @@ def discovery_bgp_peer(section: Dict[str, BgpPeer]) -> DiscoveryResult:
def check_bgp_peer(item, params, section: Dict[str, BgpPeer]) -> CheckResult:
# read params
# default monitoring states for bgpPeerState
neighborstate = {
'1': 2, # idle
'2': 1, # connect
'3': 1, # active
'4': 1, # opensent
'5': 1, # openconfirm
'6': 0, # established
}
neighborstate.update(params.get('neighborstate', neighborstate)) # update neighbor status with params
peer_not_found_state = params['peernotfound']
for bgp_connection, bgp_alias, not_found_state in params.get('peer_list', []):
......@@ -109,20 +121,16 @@ def check_bgp_peer(item, params, section: Dict[str, BgpPeer]) -> CheckResult:
if not peer.admin_state == 2: # not start
yield Result(state=State(params['admindown']), notice=f'Admin state: {peer.peer_statestr}')
else:
if peer.peer_state == 1: # idle
yield Result(state=State.CRIT, notice=f'Peer state: {peer.peer_statestr}')
elif peer.peer_state == 6: # established
if peer.peer_state == 6: # established
yield from check_levels(
value=peer.fsm_established_time,
label='Uptime',
levels_lower=params['minuptime'],
render_func=render.timespan,
metric_name='bgp_peer_fsmestablishedtime',
)
yield Result(state=State.OK, notice=f'Peer state: {peer.peer_statestr}')
else: # everything else
yield Result(state=State.WARN, notice=f'Peer state: {peer.peer_statestr}')
yield Result(state=State(neighborstate.get(str(peer.peer_state))), notice=f'Peer state: {peer.peer_statestr}')
acceptedprefixes = peer.accepted_prefixes
prefixadminlimit = peer.prefix_admin_limit
......
No preview for this file type
......@@ -2,7 +2,8 @@
# -*- coding: utf-8 -*-
from cmk.gui.plugins.views import (
inventory_displayhints, )
inventory_displayhints,
)
from cmk.gui.i18n import _
inventory_displayhints.update({
......
......@@ -12,7 +12,8 @@
# 2021-03-27: rewrite for CMK 2.0
# 2021-08-21: modified for bgp_peer plugin (from cisco_bgp_peer)
# 2021-08-29: removed htmloutput and infotext_values option
# 2022-04-02: added bgp neighbour states
#
from cmk.gui.i18n import _
from cmk.gui.valuespec import (
Dictionary,
......@@ -42,18 +43,88 @@ def _parameter_valuespec_bgp_peer():
Integer(title=_('Critical if below'), unit='seconsa', default_value=3600, minvalue=0)
],
)),
('admindown',
MonitoringState(
default_value=1,
title=_('State if peer is admin shutdown.'),
help=_('Monitoring state if the peer is admin shutdown')
)),
('peernotfound',
MonitoringState(
default_value=2,
title=_('State if peer is no not found.'),
help=_('Default monitoring state if the peer is not found in the SNMP data')
)),
('admindown',
MonitoringState(
default_value=1,
title=_('State if peer is admin shutdown.'),
help=_('Monitoring state if the peer is admin shutdown')
)),
('neighborstate',
Dictionary(
title=_('State to report for BGP neighbor state'),
help=_('Map each BGP state to a CheckMK monitoring state'),
elements=[
('1',
MonitoringState(
title=_('1 - idle'),
help=_('This is the first stage of the BGP FSM. BGP detects a start event, tries to initiate a '
'TCP connection to the BGP peer, and also listens for a new connect from a peer router. '
'If an error causes BGP to go back to the Idle state for a second time, the '
'ConnectRetryTimer is set to 60 seconds and must decrement to zero before the connection '
'is initiated again. Further failures to leave the Idle state result in the '
'ConnectRetryTimer doubling in length from the previous time. '
'Default monitoring state is "CRIT"'),
default_value=2,
)),
('2',
MonitoringState(
title=_('2 - connect'),
help=_('In this state, BGP initiates the TCP connection. If the 3-way TCP handshake completes, '
'the established BGP Session BGP process resets the ConnectRetryTimer and sends the Open '
'message to the neighbor, and then changes to the OpenSent State.'
'Default monitoring state is "WARN"'),
default_value=1,
)),
('3',
MonitoringState(
title=_('3 - active'),
help=_('In this state, BGP starts a new 3-way TCP handshake. If a connection is established, '
'an Open message is sent, the Hold Timer is set to 4 minutes, and the state moves to '
'OpenSent. If this attempt for TCP connection fails, the state moves back to the Connect '
'state and resets the ConnectRetryTimer. '
'Default monitoring state is "WARN"'),
default_value=1,
)),
('4',
MonitoringState(
title=_('4 - opensent'),
help=_('In this state, an Open message has been sent from the originating router and is awaiting '
'an Open message from the other router. After the originating router receives the OPEN '
'message from the other router, both OPEN messages are checked for errors. If the Open '
'messages do not have any errors, the Hold Time is negotiated (using the lower value), '
'and a KEEPALIVE message is sent (assuming the value is not set to zero). The connection '
'state is then moved to OpenConfirm. If an error is found in the OPEN message, a '
'Notification message is sent, and the state is moved back to Idle.'
' Default monitoring state is "WARN"'),
default_value=1,
)),
('5',
MonitoringState(
title=_('5 - openconfirm'),
help=_('In this state, BGP waits for a Keepalive or Notification message. Upon receipt of a '
'neighbor’s Keepalive, the state is moved to Established. If the hold timer expires, a '
'stop event occurs, or a Notification message is received, and the state is moved to '
'Idle. '
'Default monitoring state is "WARN"'),
default_value=1,
)),
('6',
MonitoringState(
title=_('6 - established'),
help=_('In this state, the BGP session is established. BGP neighbors exchange routes via Update '
'messages. As Update and Keepalive messages are received, the Hold Timer is reset. If the '
'Hold Timer expires, an error is detected and BGP moves the neighbor back to the Idle '
'state. '
'Default monitoring state is "OK"'),
default_value=0,
)),
])),
('noprefixlimit',
MonitoringState(
default_value=1,
......@@ -96,7 +167,7 @@ rulespec_registry.register(
CheckParameterRulespecWithItem(
check_group_name='bgp_peer',
group=RulespecGroupCheckParametersNetworking,
item_spec=lambda: TextAscii(title=_('BGP peer specific configuration'), ),
item_spec=lambda: TextAscii(title=_('BGP peer'), ),
match_type='dict',
parameter_valuespec=_parameter_valuespec_bgp_peer,
title=lambda: _('BGP peer'),
......
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