Few will deny that monitoring of Cisco devices is essential part of sysadmin’s job. I personally use Nagios to track states of BGP neighbors on Cisco routers so if one of peers goes down I’ll receive a phone call from Nagios. You may have redundant network topology but it still makes sense to know when peer goes offline, how often it happens and how fast failover router (if any) pick-ups the traffic from failed peer.

There are a few plugins for Nagios to monitoring BGP in Cisco. All of them fetch data from Cisco via SNMP so the first you need to do is to open access to your Cisco router from the host where Nagios is running. You can read more about this task on the web (for example here) but here are quick commands to open read only access:

snmp-server community myCommunity RO SNMP-MANAGEMENT
ip access-list standard SNMP-MANAGEMENT
 permit A.B.C.D
 deny any log

Where ‘myCommunity’ is name of SNMP community that will be used at Nagios host to retrieve data from Cisco router via SNMP, ‘SNMP-MANAGEMENT’ is name of ACL that opens access to SNMP only from IP address ‘A.B.C.D’ (replace with public IP address of Nagios host).

Once access to Cisco via SNMP is open you should add check_bpg plugin to Nagios:

cd /usr/lib/nagios/plugins
wget -O check_bgp.pl "http://exchange.nagios.org/components/com_mtree/attachment.php?link_id=1555&cf_id=30"
chmod +x check_bgp.pl

Now let’s check if Nagios host can actually get access to myCommunity at Cisco:

./check_bgp.pl -H 10.11.12.13 -C myCommunity -p 192.168.10.1

Where ’10.11.12.13′ is IP address of Cisco router and ’192.168.10.1′ IP address of BGP peer you need to get info about. In case of success you will see OK state and how long that peer is in state ESTABLISHED.

OK - 192.168.10.1 (AS12345) state is established(6). Established for 191d11h15m28s.

From this point it’s time to add commands to Nagios and make it to track BGP peer’s state constantly. Open Nagios’ commands.cfg config file and add there the following lines:

define command{
    command_name    check_cisco_bgp
    command_line    $USER1$/check_bgp.pl -H $HOSTADDRESS$ -C $ARG1$ -p $ARG2$
}

Then add these lines to services.cfg:

define service {
    use                             generic-service
    service_description             BGP_KPN
    host_name                       cisco-router-1
    check_command                   check_cisco_bgp!myCommunity!192.168.10.1
}

Then restart Nagios and check services summary page, you should see new BGP_KPN instance there and will receive an alert if this peer goes down.

Obviously you’ll need to add more services to specify all BPG peers and all Cisco routers you need to monitor in Nagios.

 

3 Comments

 

  1. August 15, 2012  12:52 pm by Ron Bennington Reply

    I am trying to monitor BGP peers that are in a vrf instance. I figure there is a way to edit the pl file to look in a vrf instance, would you be able to help me with this, thank you.

  2. November 4, 2012  4:25 pm by Isaías Rivera Reply

    Artem,

    Thank you very much for the tip. I was able to test the script on my server and successfully monitoring my BGP peers.

    PD: Just in case I used check_bgp.pl version 0.4.

    Cheers!,
    Isaías

  3. March 25, 2013  1:48 pm by Emmanuel Reply

    when I run the console responds OK
    But when I set it up in nagios says "null" in the outcome

Leave a reply

 

Your email address will not be published.