check_junos_bgp - Monitor Juniper™ Router's BGP tables

Usage / Command line options

% ./check_junos_bgp.pl -h
check_junos_bgp 0.1 [http://oss.teamix.org/projects/monitoringplugins]

This nagios plugin is free software, and comes with ABSOLUTELY NO WARRANTY.
It may be used, redistributed and/or modified under the terms of the 3-Clause
BSD License (see http://opensource.org/licenses/BSD-3-Clause).

Monitor Juniper™ Router's BGP tables.

Usage: check_junos_bgp [-v|--verbose] [-H <host>] [-p <port>] [-t <timeout]
[-U <user>] [-P <password] check-tuple [...]

 -?, --usage
   Print usage information
 -h, --help
   Print detailed help screen
 -V, --version
   Print version information
 --extra-opts=[section][@file]
   Read options from an ini file. See http://nagiosplugins.org/extra-opts
   for usage and examples.
 -H, --host=HOSTNAME
   Hostname/IP of Juniper box to connect to (default: localhost)
 -p, --port=PORT
   Port to connect to (default: 22)
 -U, --user=USERNAME
   Username to log into box as (default: root)
 -P, --password=PASSWORD
   Password for login username (default: <prompt>)
 -t, --timeout=INTEGER
   Seconds before plugin times out (default: 15)
 -v, --verbose
   Show details for command-line debugging (can repeat up to 3 times)

This plugin connects to a Juniper™ Router device and requests BGP table
information using the 'show bgp neighbor' command. It then checks the
specified thresholds depending on the specified checks.

A check-tuple consists of the name of the check and, optionally, a "target" 
(e.g., peer address), and warning and critical thresholds:
checkname[,target[,warning[,critical]]]

The following checks are available:
  * peers_count: Total number of peers. If a target is specified, only peers
    matching that target are taken into account.

  * prefix_count: Number of active prefixes for a single peer. If multiple
    peers match the specified target, each of those is checked against the
    specified thresholds.

Targets are either specified as IPv4/IPv6 addresses or regular expressions /
strings. In the former case, the target is compared against the peer's
address, else against the peer's description. When specifying regular
expressions, they have to be enclosed in '/'. Else, the pattern is treated as
verbatim string that has to be matched.

Warning and critical thresholds may be specified in the format documented at
http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT.

Quickstart

Check the total number of peers:

% ./check_junos_bgp.pl -H router -U nagios peers_count,,20:30,10:40
Password: 
check_junos_bgp OK - 29 peers | peers_count=29;20:30;10:40;0;

Check the number of prefixes for some peer:

% ./check_junos_bgp.pl -H router -U nagios prefix_count,<IP>,350000:400000,300000:450000
Password: 
check_junos_bgp OK - peer <IP>: 356258 prefixes | 'prefix_count[<IP>]'=356258;350000:400000;300000:450000;0;

Specifying passwords

The password for the login username may either be specified using the "-P" switch on the command line or using an INI file and the "--extra-opts" option.

% cat /etc/nagios3/plugin.ini
[junos]
password=geheim
% ./check_junos_bgp.pl <…> --extra-opts=junos@/etc/nagios3/plugin.ini <check-tuples>

For more details about the "--extra-opts" option, see http://nagiosplugins.org/extra-opts.

If no password has been specified, the plugin will prompt for it.

Command line format

% ./check_junos_bgp.pl -H router [options] check-tuple […]

Format of a "check-tuple"

checkname[,target[,warning[,critical]]]
  • Multiple checktuples may be specified as space separated list, e.g. "peers_count prefix_count"
  • Options are separated by commas (",") from the check name and other options, e.g. "prefix_count,<peer>,350000:,300000:"
    • Trailing "," may be omitted, e.g. "peers_count" is the same as "peers_count,,,"
    • The 2nd option specifies the target. Targets may either be IPv4/IPv6 addresses, a regular expression or a string. In the latter two cases, the target is compared with the peer's description. Else, the peer's address is used. Regexes have to be enclosed in slashes ("/"). Else, the string specifies an exact match.
    • Leaving out the target or leaving it empty is equivalent to an empty regex, i.e., matches all peers.
    • The 3rd (warning) and 4th (critical) options specify thresholds, see http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT for details.
    • If no target but thresholds should be used, just leave the target option empty, e.g. "peers_count,,20:30,10:40"

Implemented checks

See help output above.