MIB branch to poll for route table size

Answered Question
Aug 20th, 2010

Does anyone know if there is a standard or Cisco MIB branch that would give me the size (number of entries) in the current routing table?  I need to be able to monitor it via a simple SNMP poll.  I know I could do it with a newer embedded events manager and the ability to update the MIB from the output of "show ip route sum" but I'm looking for a simpler solution.

Thanks

I have this problem too.
0 votes
Correct Answer by Joe Clarke about 6 years 3 months ago

Actually, you don't need EEM for this.  You can use the EXPRESSION-MIB by itself to count the number of routers in the table.  See this thread for an example of how to count the number of entries in a table:

https://supportforums.cisco.com/message/3017480

The table in your case is the ipRouteTable.  The best object to count in this table is ipRouteDest.

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 5 (2 ratings)
Loading.
Correct Answer
Joe Clarke Fri, 08/20/2010 - 22:46

Actually, you don't need EEM for this.  You can use the EXPRESSION-MIB by itself to count the number of routers in the table.  See this thread for an example of how to count the number of entries in a table:

https://supportforums.cisco.com/message/3017480

The table in your case is the ipRouteTable.  The best object to count in this table is ipRouteDest.

derek.small Mon, 08/23/2010 - 11:47

Sorry Joe, but I'm missing a couple things.  Here is what I've been using, (actually the system I'm running this from doesn't have the Expression-MIB, so I'm using the numeric OID for everything, but with the Named OIDs I have....

snmpset -v 2c -c private expNameStatus.110.110.110.110.110 i 6         < ok, delete any current entry for 110.110.110.110.110
snmpset -v 2c -c private expNameStatus.110.110.110.110.110 i 5         < ok, open 110.110.110.110.110 for writting and wait
snmpset -v 2c -c private expExpressionIndex.110.110.110.110.110 u 1    < You had gauge here, but my system wouldn't accept that.
snmpset -v 2c -c private expExpressionComment.1 s "NumberOfRoutes"
snmpset -v 2c -c private expExpression.1 s '$1 >= 0'                   < Does this create a table with an entry for each route?
snmpset -v 2c -c private expObjectID.1.1 o ipRouteDest                 < This defines $1 correct?
snmpset -v 2c -c private expExpressionValueType.1 i 4                  < Should this be 4 for Integer, or 5 for IP address?
snmpset -v 2c -c private expObjectIDWildcard.1.1 i 1                   < Set this as wildcard expression
snmpset -v 2c -c private expObjectStatus.1.1 i 1                       < Do I need this since it's a wildcard exp?
snmpset -v 2c -c private expNameStatus.110.110.110.110.110 i 1         < lastly active this expression


snmpset -v 2c -c private expNameStatus.111.111.111.111.111 i 6
snmpset -v 2c -c private expNameStatus.111.111.111.111.111 i 5
snmpset -v 2c -c private expExpressionIndex.111.111.111.111.111 u 2
snmpset -v 2c -c private expExpressionComment.2 s "SumOfRoutes"
snmpset -v 2c -c private expExpression.2 s 'sum($1)'
snmpset -v 2c -c private expObjectID.2.1 o expValueInteger32Val.1.0.0  < Is this correct or should it be expValueIPAddressVal
snmpset -v 2c -c private expExpressionValueType.2 i 4
snmpset -v 2c -c private expObjectIDWildcard.2.1 i 1
snmpset -v 2c -c private xpObjectStatus.2.1 i 1
snmpset -v 2c -c private expNameStatus.111.111.111.111.111 i 1

Lastly what OID do I query to get the route count?  expValueInteger32Val.2.0.0?

derek.small Mon, 08/23/2010 - 13:02

Never mind.  I got it.  I finally looked at the first test and realized that my NMS system was putting in 1.3.6.1.2.1.4.21.1.1 for the ipRouteDest, instead of 1.3.6.1.2.1.4.21.1.8.  No idea why, but once I fixed that, it worked!  In case anyone else wants to try.....  These are the numerical OIDs incase you don't have the Expression-MIB compiled into your NMS.

snmpset -v 2c -c private 1.3.6.1.4.1.9.10.22.1.2.3.1.3.110.110.110.110.110 i 6
snmpset -v 2c -c private 1.3.6.1.4.1.9.10.22.1.2.3.1.3.110.110.110.110.110 i 5
snmpset -v 2c -c private 1.3.6.1.4.1.9.10.22.1.2.3.1.2.110.110.110.110.110 u 1
snmpset -v 2c -c private 1.3.6.1.4.1.9.10.22.1.3.1.1.4.1 s "NumberOfRoutes"
snmpset -v 2c -c private 1.3.6.1.4.1.9.10.22.1.3.1.1.2.1 s '$1 >= 0'
snmpset -v 2c -c private 1.3.6.1.4.1.9.10.22.1.3.2.1.2.1.1 o 1.3.6.1.2.1.4.21.1.8
snmpset -v 2c -c private 1.3.6.1.4.1.9.10.22.1.3.1.1.3.1 i 4
snmpset -v 2c -c private 1.3.6.1.4.1.9.10.22.1.3.2.1.3.1.1 i 1
snmpset -v 2c -c private 1.3.6.1.4.1.9.10.22.1.3.2.1.10.1.1 i 1
snmpset -v 2c -c private 1.3.6.1.4.1.9.10.22.1.2.3.1.3.110.110.110.110.110 i 1

snmpset -v 2c -c private 1.3.6.1.4.1.9.10.22.1.2.3.1.3.111.111.111.111.111 i 6
snmpset -v 2c -c private 1.3.6.1.4.1.9.10.22.1.2.3.1.3.111.111.111.111.111 i 5
snmpset -v 2c -c private 1.3.6.1.4.1.9.10.22.1.2.3.1.2.111.111.111.111.111 u 2
snmpset -v 2c -c private 1.3.6.1.4.1.9.10.22.1.3.1.1.4.2 s "SumOfRoutes"
snmpset -v 2c -c private 1.3.6.1.4.1.9.10.22.1.3.1.1.2.2 s 'sum($1)'
snmpset -v 2c -c private 1.3.6.1.4.1.9.10.22.1.3.2.1.2.2.1 o 1.3.6.1.4.1.9.10.22.1.4.1.1.4.1.0.0
snmpset -v 2c -c private 1.3.6.1.4.1.9.10.22.1.3.1.1.3.2 i 4
snmpset -v 2c -c private 1.3.6.1.4.1.9.10.22.1.3.2.1.3.2.1 i 1
snmpset -v 2c -c private 1.3.6.1.4.1.9.10.22.1.3.2.1.10.2.1 i 1
snmpset -v 2c -c private 1.3.6.1.4.1.9.10.22.1.2.3.1.3.111.111.111.111.111 i 1

To get the count of the entries in the IP route table, use the following:

snmpget -v 2c -c private 1.3.6.1.4.1.9.10.22.1.4.1.1.4.2.0.0.0

Oh, I also found out that if you don't want to have to set these after every reboot, you need to so a "write mib-data" on the router after you set them, and you might also want to issue the config command "snmp mib persist expression"

Actions

This Discussion