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'll find the necessary commands in the Not-so-Very-Static Routes section of my IP Corner article Small Site Multihoming). 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
event manager applet PingHasFailedNote: this article is part of You've asked for it series.
event track 100 state down
action 1.0 syslog msg "Ping has failed, reloading the router"
action 2.0 reload
6 comments:
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
Looks like "The default number of 5 averaged measurements"
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.
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 ?
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.
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"
This blog is using JS-Kit comments. You have to enable JavaScript if you want to post a comment.