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

update project

parent 6b22be04
No related branches found
No related tags found
No related merge requests found
......@@ -24,6 +24,7 @@
# 2020-06-04: code cleanup --> changed isdigit test to try/except loop, changed peer.get test to try/except loop
# 2020-09-10: fixed typo in metrics file. FMS --> FSM (thanks martin[dot]pechstein[at]posteo[dot]de)
# 2021-03-27: rewrite for CMK2.0
# 2021-03-28: added warning for missing admin prefix limit/warn threshold
#
# snmpwalk sample
......@@ -156,6 +157,7 @@
#
#
from dataclasses import dataclass
import re, time
from typing import Mapping, Dict, List, Tuple, NamedTuple
......@@ -180,6 +182,11 @@ from cmk.base.plugins.agent_based.agent_based_api.v1 import (
render,
)
@dataclass
class Section:
peer_prefixes: dict
peer_table: dict
###########################################################################
#
......@@ -188,7 +195,7 @@ from cmk.base.plugins.agent_based.agent_based_api.v1 import (
###########################################################################
def parse_cisco_bgp_peer(string_table: List[StringTable]):
def parse_cisco_bgp_peer(string_table: List[StringTable]) -> Section:
def bgp_render_ipv4_address(bytestring):
return ".".join(["%s" % ord(m) for m in bytestring])
......@@ -363,7 +370,10 @@ def parse_cisco_bgp_peer(string_table: List[StringTable]):
peer_table.update({'%s' % cisco_bgp_get_peer(oid_end): peer})
return [peer_prefixes, peer_table]
return Section(
peer_prefixes=peer_prefixes,
peer_table=peer_table,
)
###########################################################################
......@@ -373,9 +383,8 @@ def parse_cisco_bgp_peer(string_table: List[StringTable]):
###########################################################################
def discovery_cisco_bgp_peer(section) -> DiscoveryResult:
peer_prefixes, peer_table = section
for key in peer_prefixes.keys():
def discovery_cisco_bgp_peer(section: Section) -> DiscoveryResult:
for key in section.peer_prefixes.keys():
yield Service(item=key)
......@@ -402,7 +411,8 @@ def check_cisco_bgp_peer(item, params, section) -> CheckResult:
6: 'established'}
return names.get(state, 'unknown (%s)' % state)
peer_prefixes, peer_table = section
peer_prefixes = section.peer_prefixes
peer_table = section.peer_table
prefixes = peer_prefixes.get(item, None)
......@@ -488,7 +498,9 @@ def check_cisco_bgp_peer(item, params, section) -> CheckResult:
longoutput_data.append(['Prefix admin limit (prefixes)', '%.0d' % prefixadminlimit, ''])
longoutput_data.append(['Prefix threshold (prefixes/%)', '%.0d' % warnthreshold, '%.0d' % prefixthreshold])
else:
yield Result(state=State(params['noprefixlimit']), notice='No admin prefix limit/warn threshold configured on the device.')
warnthreshold = None
if params.get('htmloutput', False):
#
# disable 'Escape HTML codes in plugin output' in wato --> global settings
......@@ -620,6 +632,7 @@ register.check_plugin(
'minuptime': (7200, 3600),
'useaslocalas': 0,
'htmloutput': False,
'noprefixlimit': 1,
'infotext_values': [],
'peer_list': [],
},
......
No preview for this file type
......@@ -70,6 +70,14 @@ def _parameter_valuespec_cisco_bgp_peer():
totext=_('enable HTML Output for long output of check plugin (multiline)'),
default_value=False,
)),
('noprefixlimit',
MonitoringState(
default_value=1,
title=_('State if no admin prefix limit/warn threshold configured.'),
help=_('The admin prefix limit and warn threshold needs to be configured on the device. '
'For example: neighbor 172.17.10.10 maximum-prefix 10000 80. The threshold is in percentage '
'of the prefix limit')
)),
('infotext_values',
ListChoice(
title=_('Add values to check info'),
......@@ -99,7 +107,8 @@ def _parameter_valuespec_cisco_bgp_peer():
title=_('State if not found'),
help=_('You can configure an individual state if the BGP peer matching the text '
'configured in the "BGP Peer item name" field is not found')
)]),
),
]),
add_label=_('Add BGP peer'),
movable=False,
title=_('BGP Peers'),
......
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