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
That's probably ip sla threshold-type consecutive but I'm unsure about this no tried yet
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.
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 ?
event manager applet PingHasFailed
event syslog pattern "\%TRACKING-5-STATE: 100 rtr 100 reachability Up->Down"
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.
do you still have that config?
Can you pls share it?
That would be really nice.
Kind regards,
Stefan