cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
4211
Views
5
Helpful
3
Replies

EEM applet - Trigger when defined interfaces are up|down

TBear
Level 1
Level 1

Hi Everybody,

 

This is my first post so I'm new to the Cisco Community. Hopefully it will be one of many more to come.

Anyhow, I'm really hoping to get to assistance with the below as EEM scripting isn't my strength.

The script works but not 100% as I would of liked. Basically I'm trying to define the condition:

 

- If both interface tunnel 10 and tunnel 11 interface is down, then "no shutdown" interface tunnel 12.

 

Currently, when both tunnel 10 and 11 interfaces are shutdown, the script will be activated where Tunnel 12 interface will be "no shut" (this is desired)

 

Also, in the situation where Tunnel 10 is down and then up (I did "shut" and then "no shut"), when I shutdown Tunnel 11 next, the script is also activated and Tunnel 12 is up (this is not desired)

 

I believe this is happening since in the syslog, it already had in the history that tunnel 10 is down. Once Tunnel 11 is down (even though tunnel 10's state is up) the Router believes both interfaces are down hence triggering the script for tunnel 12 to be up. 

 

Is there any way I can set it so the script will only be activated when both tunnel 10 and tunnel 11 interfaces are down at the same time only? 

 

Below is my current configuration.

 

Any advise or suggestions would be most appreciated.

 

TBear,

 

--------------------------------------------------

 

ip sla 1

 icmp-echo 1.1.1.1 source-interface Tunnel10

 timeout 5000

 frequency 6

ip sla schedule 1 life forever start-time now

ip sla 2

 icmp-echo 1.1.2.1 source-interface Tunnel11

 timeout 5000

 frequency 6

ip sla schedule 2 life forever start-time now

 

track 1 ip sla 1 reachability

track 2 ip sla 2 reachability

 

event manager applet BOTH_TU10_TU11_DOWN

 event tag 1.0 track 1 state down

 event tag 2.0 track 2 state down

 trigger

  correlate event 1.0 and event 2.0

 action 01 cli command "enable"

 action 02 cli command "conf t"

 action 03 cli command "interface tu12"

 action 04 cli command "no shutdown"

 action 05 cli command "end"

1 Accepted Solution

Accepted Solutions

You should let track do most of the work here.  Create a new track, track 3 that is a boolean list:

 

track 3 list boolean or

 object 1

 object 2

 

Track 3 will be up as long as at least one of track 1 or 2 are up.  Then just look at track 3:

 

event manager applet intf-track

 event track 3 state any

 action 1.0 cli command "enable"

 action 2.0 cli command "config t"

 action 3.0 cli command "int tu12"

 action 4.0 if $_track_state eq "up"

 action 5.0  cli command "shut"

 action 6.0 else

 action 7.0  cli command "no shut"

 action 8.0 end

 action 9.0 cli command "end"

View solution in original post

3 Replies 3

TBear
Level 1
Level 1

I've managed to get it working. Thought I might share this in case someone else is looking for a solution similar to mine. I admit it's not the best solution, but it works which is the main thing.

 

If anyone else has a better suggestion / approach for writing this EEM applet, it would be nice to hear your opnion

 

----------------------------------------------------------------

event manager applet TU10_THEN_TU11_DOWN

 event tag 01 track 1

 event tag 02 track 2

  trigger

  correlate event 01 or event 02

 action 1.0 track read 1

 action 1.1 if $_track_state eq "down"

 action 2.0  track read 2

 action 2.1  if $_track_state eq "down"

 action 3.0   cli command "enable"

 action 4.0   cli command "conf t"

 action 5.0   cli command "interface tu12"

 action 6.0   cli command "no shutdown"

 action 7.0   cli command "end"

 action 8.0  end

 action 9.0 end

 

event manager applet TU11_THEN_TU10_DOWN

 event tag 01 track 1

 event tag 02 track 2

  trigger

  correlate event 01 or event 02

 action 1.0 track read 2

 action 1.1 if $_track_state eq "down"

 action 2.0  track read 1

 action 2.1  if $_track_state eq "down"

 action 3.0   cli command "enable"

 action 4.0   cli command "conf t"

 action 5.0   cli command "interface tu12"

 action 6.0   cli command "no shutdown"

 action 7.0   cli command "end"

 action 8.0  end

 action 9.0 end

 

TBear

You should let track do most of the work here.  Create a new track, track 3 that is a boolean list:

 

track 3 list boolean or

 object 1

 object 2

 

Track 3 will be up as long as at least one of track 1 or 2 are up.  Then just look at track 3:

 

event manager applet intf-track

 event track 3 state any

 action 1.0 cli command "enable"

 action 2.0 cli command "config t"

 action 3.0 cli command "int tu12"

 action 4.0 if $_track_state eq "up"

 action 5.0  cli command "shut"

 action 6.0 else

 action 7.0  cli command "no shut"

 action 8.0 end

 action 9.0 cli command "end"

Thank you soooo much!

A very clean way that works which is exactly what I needed!

 

Did not know that with track - you can add different objects to a particular list.  Very handy.

 

Cheers Joe. Appreciate your assistance.