Reload a Router When Ping Fails

One of my readers has asked an interesting question: can you reload a router when pinging a specific IP address from it fails? While there are other ways of dealing with stuck interfaces or routing processes, sometimes such a drastic measure is the only workaround, so here's how you do it:

  • Configure an IP SLA measurement. You might want to use the after parameter in the ip sla schedule command to ensure the router does not get reloaded immediately after the startup due to IP routing table not being populated.
  • Configure a tracked object based on the IP SLA measurement with the track object-id rtr sla-id reachability command
  • Configure an EEM applet that will reload the router if the tracked object enters the down state

Use configuration similar to the one below for the EEM applet:

event manager applet PingHasFailed
 event track 100 state down
 action 1.0 syslog msg "Ping has failed, reloading the router"
 action 2.0 reload

8 comments:

  1. What about thresholds? I mean if just one ping failed my router will restarted.
    That's probably ip sla threshold-type consecutive but I'm unsure about this no tried yet
  2. Looks like "The default number of 5 averaged measurements"
  3. Now I figure out you how it works. Fisrt of all you SHOULD use IP SLA schedulde start-time NOW - not after.(If IP SLA not run track rtr generate down event)
    And after you enter command
    track object-id rtr sla-id reachability
    don't forget configure delay down 60 otherwise you got infinitive rebooting router, there no such thing like threshold in this.
  4. event manager applet PingHasFailed
    event track 100 state down
    action 1.0 syslog msg "Ping has failed, reloading the router"
    action 2.0 reload

    I don't know why my 2811 router, IOS 12.4(13r) doesn't have command for event track ...
    When I type event ?, then I see the set of command as follow :(application,cli,counter,interface,ioswdsysmon,none,oir,snmp,syslog,timer)

    Is that event track command is lacking in this IOS, or it's replaced by other ?
  5. Cisco documentation (http://www.cisco.com/en/US/docs/ios/12_4t/12_4t2/ht_eem.html#wp1080886) tells you that the event track command exists only in 12.4T images.
  6. I don't want to use T images - so I do it this way
    event manager applet PingHasFailed
    event syslog pattern "\%TRACKING-5-STATE: 100 rtr 100 reachability Up->Down"
  7. Ivan,

    I have done similar EEM scripts in my role. But I don't reload the router, I only reload the 3G-HWIC instead and I do it after I miss 8x IP SLA consecutive pings at 1min intervals and default ping timeout of 5s.

    I can share my config if you wish, let me know.

    Cheers,
    Joe.
  8. Joe,

    do you still have that config?
    Can you pls share it?

    That would be really nice.

    Kind regards,
    Stefan
Add comment
Sidebar