Page 1 of 1

Check routing table of remote server

Posted: Tue May 22, 2012 3:18 pm
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

Re: Check routing table of remote server

Posted: Tue May 22, 2012 3:35 pm
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

Re: Check routing table of remote server

Posted: Tue May 22, 2012 3:35 pm
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.

Re: Check routing table of remote server

Posted: Tue May 22, 2012 4:39 pm
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

Re: Check routing table of remote server

Posted: Tue May 22, 2012 6:10 pm
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.

Re: Check routing table of remote server

Posted: Wed May 23, 2012 8:27 pm
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

Re: Check routing table of remote server

Posted: Sun May 27, 2012 6:35 pm
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.