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

cleanup

parents
No related branches found
No related tags found
No related merge requests found
# OSPF neighbors
Monitors status of OSPF neighbors.
This check is originaly from Thomas Wollner (tw[at]wollner-net[dot]de).
I changed *item* from neighbor **ID** to neighbor **IP**, added events as perfdata (incl. metrics file),\
moved part of the output to long output and done a little code cleanup to better match coding guide lines
Check Info:
* *service*: ithe check creates one service for each OSPF neighnor
* *state*:
* **critical** if the neighbor state is *down*
* **warning** if the neighbor is not in *full* or *2-way* state
* **unknown** if the agent output is invalid
* *wato*: yes
* *perfdata*: OSPF neighbor events (count)
Sample output
![sample output](/doc/sample.png?raw=true "sample [SHORT TITLE]")
title: OSPF Neighbor State Monitoring
agents: snmp
author: Thomas Wollner
license: GPLv3
distribution:
description:
This check monitors the OSPF neighborships between routers. With applied factory_settings the neighorship gets a critical state if neighborstate is down,
and a warning state if neighborship is not in state full or two-way. This behaviour can be configured via check_parameters.
Explanation of check output:
{OSPF RouterID:}
A 32-bit integer (represented as a type IpAddress) uniquely identifying the neighboring router in the Autonomous System.
{NeighborAddress:}
The IP address of this neighbor.
{NbrState:}
The State of the relationship with this Neighbor
Possible OSPF Neighbor States: (Source: http://www.cisco.com/en/US/tech/tk365/technologies_tech_note09186a0080093f0e.shtml)
{--Down}
This is the first OSPF neighbor state. It means that no information (hellos) has been received from this neighbor, but hello packets can still be sent to the neighbor in this state. During the fully adjacent neighbor state, if a router doesn't receive hello packet from a neighbor within the RouterDeadInterval time (RouterDeadInterval = 4*HelloInterval by default) or if the manually configured neighbor is being removed from the configuration, then the neighbor state changes from Full to Down.
{--Attempt}
This state is only valid for manually configured neighbors in an NBMA environment. In Attempt state, the router sends unicast hello packets every poll interval to the neighbor, from which hellos have not been received within the dead interval.
{--Init}
This state specifies that the router has received a hello packet from its neighbor, but the receiving router's ID was not included in the hello packet. When a router receives a hello packet from a neighbor, it should list the sender's router ID in its hello packet as an acknowledgment that it received a valid hello packet.
{--2-Way}
This state designates that bi-directional communication has been established between two routers. Bi-directional means that each router has seen the other's hello packet. This state is attained when the router receiving the hello packet sees its own Router ID within the received hello packet's neighbor field. At this state, a router decides whether to become adjacent with this neighbor. On broadcast media and non-broadcast multiaccess networks, a router becomes full only with the designated router (DR) and the backup designated router (BDR); it stays in the 2-way state with all other neighbors. On Point-to-point and Point-to-multipoint networks, a router becomes full with all connected routers. At the end of this stage, the DR and BDR for broadcast and non-broadcast multiacess networks are elected. For more information on the DR election process, refer to DR Election. Note: Receiving a Database Descriptor (DBD) packet from a neighbor in the init state will also a cause a transition to 2-way state.
{--Exstart}
Once the DR and BDR are elected, the actual process of exchanging link state information can start between the routers and their DR and BDR. In this state, the routers and their DR and BDR establish a master-slave relationship and choose the initial sequence number for adjacency formation. The router with the higher router ID becomes the master and starts the exchange, and as such, is the only router that can increment the sequence number. Note that one would logically conclude that the DR/BDR with the highest router ID will become the master during this process of master-slave relation. Remember that the DR/BDR election might be purely by virtue of a higher priority configured on the router instead of highest router ID. Thus, it is possible that a DR plays the role of slave. And also note that master/slave election is on a per-neighbor basis.
{--Exchange}
In the exchange state, OSPF routers exchange database descriptor (DBD) packets. Database descriptors contain link-state advertisement (LSA) headers only and describe the contents of the entire link-state database. Each DBD packet has a sequence number which can be incremented only by master which is explicitly acknowledged by slave. Routers also send link-state request packets and link-state update packets (which contain the entire LSA) in this state. The contents of the DBD received are compared to the information contained in the routers link-state database to check if new or more current link-state information is available with the neighbor.
{--Loading}
In this state, the actual exchange of link state information occurs. Based on the information provided by the DBDs, routers send link-state request packets. The neighbor then provides the requested link-state information in link-state update packets. During the adjacency, if a router receives an outdated or missing LSA, it requests that LSA by sending a link-state request packet. All link-state update packets are acknowledged.
{--Full}
In this state, routers are fully adjacent with each other. All the router and network LSAs are exchanged and the routers' databases are fully synchronized. Full is the normal state for an OSPF router. If a router is stuck in another state, it's an indication that there are problems in forming adjacencies. The only exception to this is the 2-way state, which is normal in a broadcast network. Routers achieve the full state with their DR and BDR only. Neighbors always see each other as 2-way.
{NbrOptions:}
A BIT Mask corresponding to the neighbors options field.
Bit 0, if set, indicates that the area accepts and operates on external information; of zero, it is a stub area.
Bit 1, if set, indicates that the system will operate on Type of Service metrics other than TOS 0.
If zero, the neighbor will ignore all metrics except the TOS 0 metric.
{NbrPriority:}
The priority of this neighbor in the designated router election algorithm. The value 0 signifies that the neighbor is not eligible to becom the designated router on this particular network.
{NbrEvents:}
The number of times this neighbor relationship has changed state, or an error has occurred.
{NbrPermanence:}
This variable displays the status of the entry; 'dynamic' and 'permanent' refer to how the neighbor became known.
{NbrHelloSuppressed:}
Indicates whether Hellos are being suppressed to the neighbor.
{NbrRestartHelperStatus:}
Indicates whether the router is acting as a graceful restat helper for the neighbor.
{NbrRestartHelperAge:}
Remaining time in current OSPF graceful restart interval, if the router is acting as a restart helper.
{NbrRestartHelperExitReason:}
Describes the outcome of the last attempt at acting as a graceful restart helper for the neighbor.
perfdata:
none
item:
The OSPF Neighbor address
inventory:
Inventory is supported. All OSPF neighborship entries will be inventorized.
[parameters]
parameters (dict): Dictionary based parameter is supported. You can define which neighborstate results in which nagios state
ok_states
warning_states
critical_states
example:
check_parameters += [
( {"ok_states" : [ 8, 4 ], "warning_states" : [ 2, 3, 5, 6, 7 ], "critical_states" : [ 1 ]}, [yourRouter], ["OSPF Neighbor.*"] )
]
#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
#
#
###############################################################################
# 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
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
###############################################################################
###############################################################################
# $Id: ospf_neighbor 288 2012-07-10 11:06:38Z twollner $
# Descr: OSPF Neighbor State check_mk check
# $Author: twollner $
# $Date: 2012-07-10 13:06:38 +0200 (Tue, 10 Jul 2012) $
# $Rev: 288 $
###############################################################################
# Author: Thomas Wollner (tw@wollner-net.de)
###############################################################################
#
# Th.L. 15-06-2018: changed item from neighbor id to neighbor ip
# added events as perfdata (incl. metrics file)
# moved part of the output to long output
# a little code cleanup to better match coding guide lines
#
###############################################################################
# Example Agent Output:
# OSPF-MIB
# 1.3.6.1.2.1.14.10.1.1.172.20.2.214.0 = IpAddress: 172.20.2.214
# 1.3.6.1.2.1.14.10.1.2.172.20.2.214.0 = INTEGER: 0
# 1.3.6.1.2.1.14.10.1.3.172.20.2.214.0 = IpAddress: 192.168.1.2
# 1.3.6.1.2.1.14.10.1.4.172.20.2.214.0 = INTEGER: 2
# 1.3.6.1.2.1.14.10.1.5.172.20.2.214.0 = INTEGER: 1
# 1.3.6.1.2.1.14.10.1.6.172.20.2.214.0 = INTEGER: 8
# 1.3.6.1.2.1.14.10.1.7.172.20.2.214.0 = Counter32: 6
# 1.3.6.1.2.1.14.10.1.8.172.20.2.214.0 = Gauge32: 0
# 1.3.6.1.2.1.14.10.1.9.172.20.2.214.0 = INTEGER: 1
# 1.3.6.1.2.1.14.10.1.10.172.20.2.214.0 = INTEGER: 1
# 1.3.6.1.2.1.14.10.1.11.172.20.2.214.0 = INTEGER: 2
factory_settings['ospf_neighbor_default_levels'] = {
'ok_states' : [8, 4],
'warning_states' : [2, 3, 5, 6, 7],
'critical_states': [1],
}
def inventory_ospf_neighbor(info):
inventory = []
for id, ip, rtrid, options, prio, state, events, permanence, \
hellosup, helperstatus, helperage, helperexitreason in info:
inventory.append((ip, {}))
return inventory
def check_ospf_neighbor(item, params, info):
def ospf_nbr_state(st):
names = {'1': 'down',
'2': 'attempt',
'3': 'init',
'4': 'twoWay',
'5': 'exchangeStart',
'6': 'exchange',
'7': 'loading',
'8': 'full'}
return names.get(st, st)
def ospf_nbr_permanence(st):
names = {'1': 'dynamic',
'2': 'permanent'}
return names.get(st, st)
def ospf_nbr_hellosuppressed(st):
names = {'1': 'true',
'2': 'false'}
return names.get(st, st)
def ospf_nbr_helperstatus(st):
names = {'1': 'notHelping',
'2': 'helping'}
return names.get(st, st)
def ospf_nbr_helperexitreason(st):
names = {'1': 'none',
'2': 'inProgress',
'3': 'completed',
'4': 'timedOut',
'5': 'topologyChanged'}
return names.get(st, st)
for id, ip, rtrid, options, prio, state, events, permanence, \
hellosupp, helperstatus, helperage, helperexitreason in info:
if ip == item:
nbrstatus = ospf_nbr_state(str(state))
output = 'Neighbor ID: %s' % rtrid
perfdata = []
longoutput = ''
nbrstate = int(state)
if nbrstate in params['critical_states']:
yield 2, 'State: %s' % nbrstatus
elif nbrstate in params['warning_states']:
yield 1, 'State: %s' % nbrstatus
elif nbrstate in params['ok_states']:
output += ', State: %s' % nbrstatus
else:
yield 3, 'Invalid Output from Agent'
if events:
events = int(events)
output += ', Events: %d' % events
perfdata.append(['ospf_events', events])
if options:
longoutput += '\nNeighbor options: %s' % options
if prio:
longoutput += '\nNeighbor priority: %s' % prio
if permanence:
permanencestr = ospf_nbr_permanence(str(permanence))
longoutput += '\nNeighbor permanence: %s' % permanencestr
if hellosupp:
hellosuppstr = ospf_nbr_hellosuppressed(str(hellosupp))
longoutput += '\nNeighbor hello suppressed: %s' % hellosuppstr
if helperstatus:
helperstatusstr = ospf_nbr_helperstatus(str(helperstatus))
longoutput += '\nNeighbor helper status: %s' % helperstatusstr
if helperage:
longoutput += '\nNeighbor helper age: %s' % helperage
if helperexitreason:
helperexitreasonstr = ospf_nbr_helperexitreason(helperexitreason)
longoutput += '\nNeighbor helper exit reason: %s' % helperexitreasonstr
yield 0, output + longoutput, perfdata
check_info['ospf_neighbor'] = {
'check_function' : check_ospf_neighbor,
'inventory_function' : inventory_ospf_neighbor,
'service_description' : 'OSPF neighbor %s',
'default_levels_variable': 'ospf_neighbor_default_levels',
'has_perfdata' : True,
'snmp_scan_function' : lambda oid: oid('.1.3.6.1.2.1.14.10.1.1.*') != None,
'snmp_info' : ('.1.3.6.1.2.1.14.10.1', [
OID_END,
1, # 'ospfNbrIpAddr'
3, # 'ospfNbrRtrId'
4, # 'ospfNbrOptions'
5, # 'ospfNbrPriority'
6, # 'ospfNbrState
7, # 'ospfNbrEvents'
10, # 'ospfNbrPermanence'
11, # 'ospfNbrHelloSuppressed'
12, # 'ospfNbrRestartHelperStatus'
13, # 'ospfNbrRestartHelperAge'
14, # 'ospfNbrRestartHelperExitReason'
]
),
}
doc/sample.png

16.5 KiB

File added
{'author': u'Thomas Wollner',
'description': u'OSPF Neighborship State Check\n\nTh.L. 15-06-2018: changed item from neighbor id to neighbor address\n added events as perfdata (incl. metrics file)\n moved part of the output to long output\n',
'download_url': 'http://exchange.check-mk.org/',
'files': {'checkman': ['ospf_neighbor'],
'checks': ['ospf_neighbor'],
'web': ['plugins/metrics/ospf_neighbor.py']},
'name': 'ospf_neighbor',
'num_files': 3,
'title': u'OSPF Neighbor State Check',
'version': '20180806.v1.2',
'version.min_required': '1.2.8b8',
'version.packaged': '1.4.0p35'}
\ No newline at end of file
#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
#
# OSPF neighbor metrics plugin
#
# Author: Th.L.
# Date : 2018-06-15
#
#####################################################################################################################
#
# define units for OSPF neighbor perfdata
#
#####################################################################################################################
#####################################################################################################################
#
# define metrics for OSPF neighbor perfdata
#
#####################################################################################################################
metric_info['ospf_neighbor_ospf_events'] = {
'title': _('Events'),
'unit': 'count',
'color': '26/a',
}
######################################################################################################################
#
# map OSPF neighbor perfdata to metric
#
######################################################################################################################
check_metrics['check_mk-ospf_neighbor'] = {
'ospf_events': {'name': 'ospf_neighbor_ospf_events', },
}
######################################################################################################################
#
# how to graph perdata for OSPF neighbor
#
######################################################################################################################
graph_info.append({
'title': _('OSPF neighbor events'),
'metrics': [
('ospf_neighbor_ospf_events', 'area'),
],
})
######################################################################################################################
#
# define perf-o-meter for OSPF neighbor events
#
######################################################################################################################
perfometer_info.append({
'type': 'linear',
'segments': ['ospf_neighbor_ospf_events'],
'total': 100,
})
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