banshee is under active development: collectors will keep changing, and a version you publish will likely need adjustments. For stable use, wait for version 1.0.0.

Network

banshee/network-collection/network/snmp/

ospf-neighbors

The OSPF neighbors of a router by SNMP (OSPF-MIB): the state of each adjacency, its flaps, and a neighbor that is gone.

  • network
  • snmp
  • ospf
  • ospf-mib
  • router
  • routing

by banshee1 installation2 versions

Keen 1.0.0 · 49 lines
// The OSPF neighbors of a router, by SNMP (OSPF-MIB, RFC 4750): the state of each adjacency and its
// events, which show a neighbor that flaps, and the number of neighbors. A neighbor is named by its
// address. A neighbor that falls leaves the table after its dead interval: it is seen as a neighbor
// missing, or as a neighbor count below the threshold.
// OSPF-MIB is OSPFv2, IPv4 only; OSPFv3 has its own MIB.
need('protocol:snmp');

per('neighbor', 'Neighbors');
output('state', 'text', array('label' => 'Adjacency state', 'per' => 'neighbor'));
output('events', 'number', array('label' => 'State changes', 'per' => 'neighbor'));
output('neighbors', 'number', array('label' => 'Neighbors'));

watch.below('no-neighbor', 'No neighbor', 'neighbors', array('critical' => 1));
watch.expect('not-adjacent', 'Adjacency not formed', 'state', array(
    'help'     => 'Critical when a neighbor stays neither full nor two-way, the normal state between two routers that are not designated.',
    'critical' => array('full', 'two-way'),
    'for'      => '3 runs',
));
watch.missing('missing', 'Missing neighbor', 'state', array('enabled' => false));
watch.increase('flapping', 'Adjacency flapping', 'events', array('warning' => 20, 'window' => '1 h', 'enabled' => false));

// ospfNbrTable, by ospfNbrIpAddr and ospfNbrAddressLessIndex (five numbers: the address, then 0 for a
// neighbor on a numbered interface): ospfNbrState and ospfNbrEvents.
$neighbors = snmp.table(array(
    'state'  => '1.3.6.1.2.1.14.10.1.6',
    'events' => '1.3.6.1.2.1.14.10.1.7',
));

// ospfNbrState in words.
$states = array(1 => 'down', 2 => 'attempt', 3 => 'init', 4 => 'two-way', 5 => 'exchange-start', 6 => 'exchange', 7 => 'loading', 8 => 'full');

$count = 0;
foreach ($neighbors as $index => $row) {
    $parts = text.split($index, '.');
    if (list.count($parts) != 5) {
        continue;
    }
    // A neighbor on an unnumbered interface carries its interface index.
    $name = $parts[0] . '.' . $parts[1] . '.' . $parts[2] . '.' . $parts[3];
    if ($parts[4] != 0) {
        $name = $name . ' #' . $parts[4];
    }
    $count = $count + 1;
    value('state', list.get($states, list.get($row, 'state', 0), 'unknown'), $name);
    if (list.has($row, 'events')) {
        value('events', $row['events'], $name);
    }
}
value('neighbors', $count);