Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

Adding Conditions to an EEM Script

Hello

I have a script that reboots router if a ping (IP SLA) ha failed and the only issue with this is that if the site that I am pinging goes down, or the service provider goes down, the router will get cought in "reboot loop". Is there a way to add a condition saying that if the router has been up for X number if hours do not reboot or process the script.

Here is my script below.

Many thanks in advance

Jeff

ip sla 100

icmp-echo 192.168.1.25 source-interface Loopback0

timeout 500

frequency 10

ip sla schedule 100 life forever start-time now

!

event manager applet PingHasFailed

event track 100 state down

action 1.0 syslog msg "Ping has failed, reloading the router"

action 2.0 reload

1 ACCEPTED SOLUTION

Accepted Solutions
Cisco Employee

Re: Adding Conditions to an EEM Script

Sure, you can add such a condition, but I'm not sure how checking for hours of uptime will prevent the loop.  That is, if the router reloads (for any reason), and when it comes back, the host in question is not reachable, then the router will still continue to reload.  What you might want instead is this to use nesting.  For example:

event manager environment quote "

!

event manager applet track-up

event track 100 state up

action 1.0 cli command "enable"

action 2.0 cli command "config t"

action 3.0 cli command "event manager applet track-down"

action 4.0 cli command "event track 100 state down"

action 5.0 cli command "action 1.0 syslog msg $quote Ping has failed, reloading the router$quote"

action 6.0 cli command "action 2.0 reload"

action 7.0 cli command "end"

!

event manager applet remove-track-down

event syslog pattern "SYS-5-RESTART"

action 1.0 cli command "enable"

action 2.0 cli command "config t"

action 3.0 cli command "no event manager applet track-down"

action 4.0 cli command "end"

Using these policies, you will only see the reload if the track had been up.  On a reload, the track-down applet (if it still exists) will be removed.

3 REPLIES
Cisco Employee

Re: Adding Conditions to an EEM Script

What version of IOS are you running?

New Member

Re: Adding Conditions to an EEM Script

Version 15.1(1)T

Cisco Employee

Re: Adding Conditions to an EEM Script

Sure, you can add such a condition, but I'm not sure how checking for hours of uptime will prevent the loop.  That is, if the router reloads (for any reason), and when it comes back, the host in question is not reachable, then the router will still continue to reload.  What you might want instead is this to use nesting.  For example:

event manager environment quote "

!

event manager applet track-up

event track 100 state up

action 1.0 cli command "enable"

action 2.0 cli command "config t"

action 3.0 cli command "event manager applet track-down"

action 4.0 cli command "event track 100 state down"

action 5.0 cli command "action 1.0 syslog msg $quote Ping has failed, reloading the router$quote"

action 6.0 cli command "action 2.0 reload"

action 7.0 cli command "end"

!

event manager applet remove-track-down

event syslog pattern "SYS-5-RESTART"

action 1.0 cli command "enable"

action 2.0 cli command "config t"

action 3.0 cli command "no event manager applet track-down"

action 4.0 cli command "end"

Using these policies, you will only see the reload if the track had been up.  On a reload, the track-down applet (if it still exists) will be removed.

387
Views
0
Helpful
3
Replies