cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3566
Views
0
Helpful
4
Replies
peterbe
Beginner

eem script to trigger another script to run in x hours

We are using EEM to increase OSPF cost on primary link if OSPF flaps a couple of times in 5-minutes or IPS SLA detects an issue.  The traffic then uses an alternate link until OSPF cost is retutned to normal.

Now we want to automate restoring OSPF cost to normal a couple of hours after last OSPF flap or IP SLA event.  Notice I said 'last' so if link is faulty for several hours we do not want to restore OSPF cost until it has been stable for a period of time.

Need suggestions on how to setup a timer so that is can be reset if link flaps again before it has timed out?

Thanks

Peter

1 ACCEPTED SOLUTION

Accepted Solutions
Joe Clarke
Hall of Fame Cisco Employee

No, you have to create the timer applet from within your "up" applet.

event manager environment q "

action 1.0 cli command "enable"

action 2.0 cli command "config t"

action 3.0 cli command "event manager applet OSPFCOSTTIMER"

action 4.0 cli command "event timer countdown time 300"

action 5.0 cli command "action 1.0 syslog msg $q OSPF COST RESTORE TIMER TEST$q"

action 6.0 cli command "end"

View solution in original post

4 REPLIES 4
Joe Clarke
Hall of Fame Cisco Employee

This is typically simpler than you might think.  Have the policy that detects the IPSLA "up" event install a timer countdown policy that counts down the desired number of "stable" seconds.  If that timer is allowed to get to zero, then the link is restored.  If, however, you have another flap, have your "down" event remove that countdown timer policy.  Thus the link will not be restored.

Thanks Joseph.  Your solution sounds great.

I cannot work out how to install a timer countdown policy.  On a test router tried:

event manager applet OSPFCOSTTIMER

description OSPF RESTORE COST TIMER

event timer countdown name TIMER time 300

action 1.0 syslog msg "OSPF COST RESTORE TIMER TEST"

event manager applet OSPFUP

  description OSPF UP

  event..... (trigger on OSPF UP)

  action 1.0  policy OSPFCOSTTIMER

But OSPFUP get an error executing statement 1.0.  I have not done much EEM so guess I am doing it wrong.

Also, how do I remove the countdown (OSPFCOSTTIMER) policy for an OSPF down?

Joe Clarke
Hall of Fame Cisco Employee

No, you have to create the timer applet from within your "up" applet.

event manager environment q "

action 1.0 cli command "enable"

action 2.0 cli command "config t"

action 3.0 cli command "event manager applet OSPFCOSTTIMER"

action 4.0 cli command "event timer countdown time 300"

action 5.0 cli command "action 1.0 syslog msg $q OSPF COST RESTORE TIMER TEST$q"

action 6.0 cli command "end"

View solution in original post

Excellent. Thanks for your help.