Check routing table of remote server

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
duffrecords
Posts: 3
Joined: Tue May 22, 2012 3:09 pm

Check routing table of remote server

Post by duffrecords »

I need to check a remote server's routing table to make sure a specific route is included and, if not, send an alert. The remote server has SNMP set up but I'm not really familiar with the MIB syntax. If I were to use the check_snmp plugin, what would the appropriate check_command be? I want to make sure the following line exists (the first IP address is realistically the only string I need to search for):

Code: Select all

10.0.1.0        10.80.0.1       255.255.255.0   UG    0      0        0 eth1
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Check routing table of remote server

Post by lmiltchev »

I found this link on the Nagios Exchange - not sure if this plugin could check for a particular string:

http://exchange.nagios.org/directory/Pl ... le/details
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
nscott
Posts: 1040
Joined: Wed May 11, 2011 8:54 am

Re: Check routing table of remote server

Post by nscott »

duff,

Well, if its a static route and you can bank on it being in the same OID (that long .1.2.3.4.5.3.2.3.4.5) number, you can use check_snmp, if its a dynamic route you'll have to use something else. This looks promising: http://exchange.nagios.org/directory/Pl ... le/details

If it is a static route, you'll need to have the MIB that you expect it to be at and then use a regular expression, your check might look something liek this:

check_snmp -H <router ip> -C <community string> -o <OID of the route> -r '^STRING: 10\.0\.1\.\0'

Will return OK if the OID begins with STRING: 10.0.1.0

otherwise it will show CRITICAL.
Nicholas Scott
Former Nagios employee
duffrecords
Posts: 3
Joined: Tue May 22, 2012 3:09 pm

Re: Check routing table of remote server

Post by duffrecords »

How do I find the correct OID for the routing table? I did a web search and found a few possible ones but they all result in the same error:

Code: Select all

External command error: Error in packet
Reason: (noSuchName) There is no such variable name in this MIB.
Failed object: iso.3.6.1.2.1.4.21
User avatar
jsmurphy
Posts: 989
Joined: Wed Aug 18, 2010 9:46 pm

Re: Check routing table of remote server

Post by jsmurphy »

Find out which mib file(s) is relevant for your device then look that mib up on oidview.com, a similar site or a mib viewing app and find the entry relevant to the routing table. This is probably the most sure fire way to find the correct oid.
duffrecords
Posts: 3
Joined: Tue May 22, 2012 3:09 pm

Re: Check routing table of remote server

Post by duffrecords »

It should be RFC1213. For example, the OID for ipRouteNextHop is 1.3.6.1.2.1.4.21.1.7. On the remote server I can query it and get a bunch of info:

Code: Select all

$ snmpwalk -v2c -c public -m +RFC1213-MIB localhost 1.3.6.1.2.1.4.21.1.7
RFC1213-MIB::ipRouteNextHop.0.0.0.0 = IpAddress: (redacted)
RFC1213-MIB::ipRouteNextHop.10.0.1.0 = IpAddress: 10.80.0.1
RFC1213-MIB::ipRouteNextHop.10.80.0.0 = IpAddress: 0.0.0.0
RFC1213-MIB::ipRouteNextHop.10.80.16.1 = IpAddress: 0.0.0.0
RFC1213-MIB::ipRouteNextHop.(redacted) = IpAddress: 0.0.0.0
RFC1213-MIB::ipRouteNextHop.127.0.0.0 = IpAddress: 0.0.0.0
but when I run check_snmp on the Nagios server I get the same error:

Code: Select all

$ ./check_snmp -H 10.80.10.1 -C public -o 1.3.6.1.2.1.4.21.1.7 -m RFC1213-MIB
External command error: Error in packet
Reason: (noSuchName) There is no such variable name in this MIB.
Failed object: RFC1213-MIB::ipRouteNextHop
User avatar
jsmurphy
Posts: 989
Joined: Wed Aug 18, 2010 9:46 pm

Re: Check routing table of remote server

Post by jsmurphy »

In your example above you are running the SNMP walk query against the localhost:

snmpwalk -v2c -c public -m +RFC1213-MIB localhost 1.3.6.1.2.1.4.21.1.7

Not the remote host.
Locked