diff --git a/agent_based/ospf_neighbor.py b/agent_based/ospf_neighbor.py index 0b1662a6496cb99a7cfbbe2f21ffd602a135ba84..186f5e2bdc49d8d7d2ea723673a9d395bf63f721 100644 --- a/agent_based/ospf_neighbor.py +++ b/agent_based/ospf_neighbor.py @@ -1,7 +1,6 @@ #!/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', ) diff --git a/ospf_neighbor.mkp b/ospf_neighbor.mkp index f53c528d4152ff900f6478b5c36304833055d6d2..825399809418c202d2535f282c00a9c8f9b7debe 100644 Binary files a/ospf_neighbor.mkp and b/ospf_neighbor.mkp differ diff --git a/packages/ospf_neighbor b/packages/ospf_neighbor index b05a2c8dd0f7c126c1b5f676b4d53f241a1fb566..3676f22991683bb2e4dd115db5631d20a07ac8fd 100644 --- a/packages/ospf_neighbor +++ b/packages/ospf_neighbor @@ -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 diff --git a/web/plugins/wato/ospf_neighbor.py b/web/plugins/wato/ospf_neighbor.py index 7b4122fb8bdcfb0a28a9a3af3fb759ba4882fdc9..16c9b985e478f1db325cd43c982ec6a1f509268e 100644 --- a/web/plugins/wato/ospf_neighbor.py +++ b/web/plugins/wato/ospf_neighbor.py @@ -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'),