Monday, September 09, 2013

Monitoring BGP using NAGIOS

We can use check_bgp NAGIOS plugin for monitoring BGP. Visit  http://exchange.nagios.org/directory/Plugins/Network-Protocols/BGP-2D4/check_bgp/details for more details.

How to install and configure check_bgp plugin?

In the demonstration, I will be using NAGIOS server installed in Ubuntu Linux, and i want to monitor BGP in a Cisco ASR 1006 router. Since this plugin uses BGP4-MIB and SNMP, It can be used to monitor any router with SNMP.
  1. Download check_bgp.pl perl script from the link given above. 0.4 is the recent version.
  2. Now move this perl script to /usr/lib/nagios/plugins directory using the command
    sudo mv check_bgp.pl /usr/lib/nagios/plugins
  3. Make the perl script executable.
     sudo chmod +x /usr/lib/nagios/plugins/check_bgp.pl
  4. Now before adding the command definition to NAGIOS, test the plugin from BASH terminal. Syntax is as follows:
     /usr/lib/nagios/plugins/check_bgp.pl -H <Router IP> -C <SNMP communitystring configured in router> -p <BGP Neighbour IP to monitor>

    If you get output from the plugin, you can proceed to add command definition and Service definition in NAGIOS.
  5. Now define a command and a service for the host object Router in NAGIOS as follows:
    
     define command {
       command_name check_bgp
       command_line /usr/lib/nagios/plugins/check_bgp.pl -H $HOSTADDRESS$ -C    $ARG1$ -p $ARG2$
     }
    define service{
       use     generic-service         ; Name of service template to use
       host_name   corerouter
       service_description   BGP states-iBGP
       check_command         check_bgp!iol!10.52.162.253
      }