This is the first custom probe I have written and I ran into some problems that I had to kludge around in the probe. I'd love to hear if there is a better way to do this.
The biggest problem is that the table in the Juniper BGP MIB that has the per peer prefixes is not indexed by the peer IP address, but rather by something they call the "jnxBgpM2PeerIndex" that can change depending on the order that the peers are configured on the router. There is a separate table that maps peer IP addresses to jnxBgpM2PeerIndex values.
Naturally for the probe configuration you want to be able to enter in the peer IP address since that is a known quantity. I need to be able to take that IP address, look up the jnxBgpM2PeerIndex, and then use the jnxBgpM2PeerIndex as part of the OID that retrieves the number of prefixes received. I was hoping to do something like this:
<snmp-device-variables>
jnxBgpM2PeerIndex, 1.3.6.1.4.1.2636.5.1.1.2.1.1.1.14.0.1.0.0.0.0.1.${BGP Peer IP}, DEFAULT
BGP.Peer.Prefixes, 1.3.6.1.4.1.2636.5.1.1.2.6.2.1.7.${jnxBgpM2PeerIndex}.1.1, DEFAULT
</snmp-device-variables>
I want to have that first OID retrieved and then use that value as part of the second OID. I tried this, and could not get it to work (perhaps because the parsing of the probe is done before the OID value has been retrieved?). So I ended up making a jnxBgpM2PeerIndexParam that is a config parameter in addition to the jnxBgpM2PeerIndex that is retrieved by SNMP. So when you first set up the probe you type in the peer IP address, and leave jnxBgpM2PeerIndexParam blank (since you don't know it). After the first probe run, you then open the status window and copy out the jnxBgpM2PeerIndex value and paste that into the probe configuration. This is rather kludgy, but it's the best I could come up with.
If the jnxBgpM2PeerIndex of the peer changes for some reason, the probe will go into alarm and request human intervention (look at the status window for the new jnxBgpM2PeerIndex value and put that into the probe config). That's some protection, but still yucky.
Is there a better way to do this? I'm open to suggestions! :)
The other problem I encountered was in using the LEGEND field in the <snmp-device-variables> section. I want to have something like this:
<snmp-device-variables>
[...]
BGP.Peer.Prefixes,1.3.6.1.4.1.2636.5.1.1.2.6.2.1.7.${jnxBgpM2PeerIndexParam}.1.1,DEFAULT,"# of prefixes received via BGP from ${BGP Peer Name}"
</snmp-device-variables>
and then reference it in the snmp-device-display section like this:
<snmp-device-display>
\B5\BGP Prefix Info for BGP Peer "${BGP Peer Name}" (${BGP Peer IP})\0P\
\4\ ${BGP.Peer.Prefixes:legend}=\0\ ${BGP.Peer.Prefixes}
[...]
</snmp-device-display>However, this doesn't work correctly. In the status window I see literally
"# of prefixes received via BGP from ${BGP Peer Name}" instead of expanding ${BGP Peer Name} to its value. The docs say that the LEGEND field can use variables that will be expanded, so I'm not sure what I'm doing wrong. Is it because I'm using the ":legend" postfix on a legend that has a variable embedded?
Mahalo for any assistance the list can provide! -- Robert Brewer ph: 808-532-8246 Assistant Manager, System Department fax: 808-529-0596 LavaNet, Inc. [EMAIL PROTECTED]<!--
SNMP - BGP Peer Prefix Count (Juniper) (net.lava.snmp.bgp-prefixes-jnx)
BGP Peer # of Prefixes on Juniper routers Custom SNMP Probe.
Custom Probe for InterMapper (http://www.intermapper.com)
Robert Brewer, LavaNet Inc., April 2005, [EMAIL PROTECTED]
Inspired by "SNMP - BGP" probe by "Dennis O'Reilly, University of British Columbia, May 2003, [EMAIL PROTECTED]"
-->
<header>
type = "custom-snmp"
package = "net.lava"
probe_name = "snmp.bgp-prefixes-jnx"
human_name = "SNMP - BGP Peer Prefix Count (Juniper)"
version = "0.87"
address_type = "IP"
port_number = "161"
flags = "NOLINKS,SNMPV2C"
</header>
<description>
\GB\SNMP - BGP Peer Prefix Count (Juniper)\P\
This probe monitors the number of prefixes received from a particular BGP peer on a Juniper JUNOS router using the \2U=http://www.juniper.net/techpubs/software/junos/junos70/swconfig70-net-mgmt/html/mib-jnx-bgpmib2.txt\BGP4-V2-MIB-JUNIPER MIB\P0\, and generates alarms when the number of prefixes drops below various thresholds (usually indication of a problem upstream). To monitor multiple BGP peering sessions, create multiple instances of this probe.
An unfortunate complexity is that the SNMP table that contains the prefix info is not indexed by IP address, rather it is indexed by a \i\jnxBgpM2PeerIndex\p\ that can change depending on the order that peers are configured on the router. Intermapper's custom SNMP probe type does not seem to be able to handle this type of indirection automatically, so you must enter the IP address of the peer and then check the resulting jnxBgpM2PeerIndex value and then come back and reconfigure the probe with that value as well. If the jnxBgpM2PeerIndex for the peer IP address changes (due to router reboot, disabling and re-enabling a peer, etc), the probe will go into alarm state and a human will have to check the new value in the status window and change the probe configuration.
Note that this probe does not work on Cisco routers. There is a comparable enterprise MIB from Cisco (\2U=http://www.cisco.com/en/US/products/sw/iosswrel/ps1839/products_feature_guide09186a0080110bbc.html\CISCO-BGP4-MIB\P0\) that should be usable, but this probe would have to be modified to make that work.
\i\BGP Peer IP\p\ is the IP address of the BGP peer. Typically this is another router owned and operated by another service provider.
\i\BGP Peer Name\p\ is the name of the BGP peer.
\i\jnxBgpM2PeerIndex\p\ is the jnxBgpM2PeerIndex of the BGP peer, which must be determined by SNMP query to the jnxBgpM2PeerTable object.
\i\Low Prefix Count Threshold\p\, if the number of prefixes received is below this number, a warning will be raised.
\i\Very Low Prefix Count Threshold\p\, if the number of prefixes received is below this number there is a serious problem and an alarm will be raised.
</description>
<parameters>
"BGP Peer IP" = "10.0.0.0" "BGP Peer Name" = "BGP Peer" "jnxBgpM2PeerIndexParam" = "1" "Low Prefix Count Threshold" = "100000" "Very Low Prefix Count Threshold" = "100"
</parameters>
<snmp-device-variables>
-- TYPE can be one of: DEFAULT, PER-SECOND, PER-MINUTE, TOTAL-VALUE.
-- Use DEFAULT for string and integer values.
-- MIB Variable -- --- OID ---
--- TYPE --- --- LEGEND ---jnxBgpM2PeerIndex, 1.3.6.1.4.1.2636.5.1.1.2.1.1.1.14.0.1.0.0.0.0.1.${BGP Peer IP}, DEFAULT
-- BGP.Peer.Prefixes, 1.3.6.1.4.1.2636.5.1.1.2.6.2.1.7.${jnxBgpM2PeerIndexParam}.1.1, DEFAULT, "# of prefixes received via BGP from ${BGP Peer Name}"
BGP.Peer.Prefixes, 1.3.6.1.4.1.2636.5.1.1.2.6.2.1.7.${jnxBgpM2PeerIndexParam}.1.1, DEFAULT, "# of prefixes received via BGP"
</snmp-device-variables>
<snmp-device-thresholds>
alarm: ${jnxBgpM2PeerIndexParam} != ${jnxBgpM2PeerIndex} "jnxBgpM2PeerIndex changed, requires human attention and update"
warning: ${BGP.Peer.Prefixes} < ${Low Prefix Count Threshold} "low received prefix count"
alarm: ${BGP.Peer.Prefixes} < ${Very Low Prefix Count Threshold} "extremely low received prefix count"
</snmp-device-thresholds>
<snmp-device-display>
\B5\BGP Prefix Info for BGP Peer "${BGP Peer Name}" (${BGP Peer IP})\0P\
\4\ ${BGP.Peer.Prefixes:legend}=\0\ ${BGP.Peer.Prefixes}
\4\ jnxBgpM2PeerIndex=\0\ ${jnxBgpM2PeerIndex}</snmp-device-display>
