BGP4-MIB support for Bird
Thursday February 24th 2011, 4:05 pm
Filed under: Software

I’ve written a small python daemon which exposes parts of Bird through an AgentX interface under the BGP4-MIB. This allows you to poll the BGP status of your Bird installs through SNMP, which in turn allows you to import this status information into applications (for instance, Observium). Unfortunately, BGP4-MIB does not support IPv6, so this daemon doesn’t do that either.

The following objectTypes are supported:
– bgpLocalAs
– bgpPeerFsmEstablishedTime
– bgpPeerHoldTime
– bgpPeerHoldTimeConfigured
– bgpPeerIdentifier
– bgpPeerInUpdates
– bgpPeerKeepAlive
– bgpPeerKeepAliveConfigured
– bgpPeerLocalAddr
– bgpPeerLocalPort
– bgpPeerOutTotalMessages
– bgpPeerOutUpdates
– bgpPeerRemoteAddr
– bgpPeerRemoteAs
– bgpPeerRemotePort
– bgpPeerState
– bgpVersion

To use this program, you need the following packages:
– Net-SNMP
– Python
– Bird

The script uses the bird cli client to fetch most information, but since the script also parses your Bird configuration file, it can be picky about the way you layout this file. For now, you’ll need the following structure within your BGP protocol statements. The fields between [ and ] are required:

protocol bgp [name] {
local as [asnum];
neighbor [ipaddr] as [asnum];

Also, since this script uses the protocol timeformat to report the uptime of the BGP session, you need a modified timeformat in your configuration. Add the following global option:

timeformat protocol "%s";

Download the code here, and verify it’s MD5 sum.

5 Comments so far

A Idea? (not the agents)

Warning: Failed to connect to the agentx master agent ([NIL]):
MIB search path: /root/.snmp/mibs:/usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf:/usr/share/mibs/site:/u
Cannot find module (SNMPv2-SMI): At line 9 in /usr/local/share/bird-snmp/BGP4-MIB.txt
Did not find ‘mib-2’ in module #-1 (/usr/local/share/bird-snmp/BGP4-MIB.txt)
Unlinked OID in BGP4-MIB: bgp ::= { mib-2 15 }
Undefined identifier: mib-2 near line 13 of /usr/local/share/bird-snmp/BGP4-MIB.txt
Traceback (most recent call last):
File “/usr/local/bin/bird-agentx”, line 6, in
bird_agentx = Bird(“/etc/bird/bird.conf”, ‘/usr/sbin/birdc’)
File “/usr/local/lib/python2.7/dist-packages/bird/”, line 260, in __init__
rootoid = “BGP4-MIB::bgp”,
File “/usr/local/lib/python2.7/dist-packages/bird/”, line 498, in Init
oidOID = ReadOID(rootoid)
File “/usr/local/lib/python2.7/dist-packages/bird/”, line 223, in ReadOID
raise OperationalError(‘Incorrect OID (%(oid)s)’ % { ‘oid’ : TextOID })
bird.agentx.OperationalError: Incorrect OID (BGP4-MIB::bgp)

Comment by Geno 12.01.15 @ 1:58 pm

Hi!, do you casually have a OSPF version? ☺

Comment by Ciro 12.05.15 @ 5:28 am

Is this available on github? I made a few modifications to your script and want to share with the community.

Comment by Renato Ornelas 04.20.16 @ 3:25 am

Hi Renato

Could you send me modified code ?


Comment by Piotr 11.13.16 @ 10:43 pm

Please help, bird-agentx falling on:
Traceback (most recent call last):
File “/usr/local/bin/bird-agentx”, line 6, in
bird_agentx = Bird(“/etc/bird.conf”, ‘/usr/sbin/birdc’)
File “/usr/local/lib/python2.7/dist-packages/bird/”, line 252, in __init__
self.cfg = BirdConfig(cfgfile, cli)
File “/usr/local/lib/python2.7/dist-packages/bird/”, line 91, in __init__
File “/usr/local/lib/python2.7/dist-packages/bird/”, line 188, in fetch_cfg
cfg = self._get_values()
File “/usr/local/lib/python2.7/dist-packages/bird/”, line 141, in _get_values
cfg[cur_proto][“bgpPeerFsmEstablishedTime”] = cur – t
KeyError: ‘csrv’

Comment by Interhost 04.22.17 @ 10:24 am

Leave a comment
Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>