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

update project

parent 153d09f0
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
#
###############################################################################
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -182,7 +181,7 @@ def discovery_ospf_neighbor(section: Dict[str, OspfNeighbor]) -> DiscoveryResult
def check_ospf_neighbor(item, params, section: Dict[str, OspfNeighbor]) -> CheckResult:
def ospf_nbr_state(st):
def ospf_nbr_state(st: str) -> str:
names = {'1': 'down',
'2': 'attempt',
'3': 'init',
......@@ -193,7 +192,7 @@ def check_ospf_neighbor(item, params, section: Dict[str, OspfNeighbor]) -> Check
'8': 'full'}
return names.get(st, 'unknown: %s' % st)
# default checkmk states for ospfNbrState
# default monitoring states for ospfNbrState
neighborstate = {
'1': 2, # down
'2': 1, # attempt
......@@ -205,18 +204,18 @@ def check_ospf_neighbor(item, params, section: Dict[str, OspfNeighbor]) -> Check
'8': 0, # full
}
notFoundState = 2
not_found_state = params['state_not_found', 3]
for neighbour, neighbourAlias, neighbourNotFoundState in params.get('peer_list', []):
if item == neighbour:
yield Result(state=State.OK, summary=f'[{neighbourAlias}]')
notFoundState = neighbourNotFoundState
not_found_state = neighbourNotFoundState
try:
neighbor = section[item]
except KeyError:
yield Result(state=State(notFoundState), notice='Item not found in SNMP data')
return
yield Result(state=State(not_found_state), notice='Item not found in SNMP data')
return
yield Result(state=State.OK, summary=f'Neighbor ID: {neighbor.rtrid}')
......@@ -267,6 +266,7 @@ register.check_plugin(
discovery_function=discovery_ospf_neighbor,
check_function=check_ospf_neighbor,
check_default_parameters={
'state_not_found': 3,
},
check_ruleset_name='ospf_neighbor',
)
No preview for this file type
......@@ -17,7 +17,7 @@
'name': 'ospf_neighbor',
'num_files': 4,
'title': 'OSPF Neighbor State Check',
'version': '20210915.v1.4',
'version': '20210915.v1.4a',
'version.min_required': '2.0.0',
'version.packaged': '2021.07.14',
'version.usable_until': None}
\ No newline at end of file
......@@ -32,6 +32,12 @@ def _parameter_valuespec_ospf_neighbor():
return Transform(
Dictionary(
elements=[
('state_not_found',
MonitoringState(
title=_('State to report if neighbor not found'),
help=_('Monitoring state if the neighbor not found in the SNMP data.'),
default_value=3,
)),
('neighborstate',
Dictionary(
title=_('State to report for OSPF neighbor state'),
......
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