cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2734
Views
2
Helpful
7
Replies

EEM to activate when a track goes down

alnic123
Level 1
Level 1

I currently have a 1117 4g router that has an ADSL connection with a cellular backup. I have created an EEM script that changes the tunnel source in tunnel5 when the ADSL connection goes down by using a track.

I have noticed that this works fine if the track is up when I apply the EEM config, the applet will activate and change the tunnel source. But if I apply it when the Track is already down there is nothing to "activate it".

I have tried using "event timer watchdog time 10" but this makes the applet run every 10 seconds regardless of if the track is down. Is there a way to get this to run ONLY if track 70 is down?

event manager applet TunnelChange
event track 70 state down
event timer watchdog time 10
action 1.0 cli command "enable"
action 2.0 cli command "configure term"
action 3.0 cli command "interface Tunnel5"
action 4.0 cli command "tunnel source Cellular0/2/0"

Thanks

7 Replies 7

There are two eem when track up and down

Just end both eem with cli command "exit"

Yes i have that already, here is the full thing. 
It runs every 10 seconds, checks track70 is down and activates TunnelChange every time

event manager applet TunnelChange
event track 70 state down
event timer watchdog time 10
action 1.0 cli command "enable"

action 2.0 cli command "configure term"

action 3.0 cli command "interface Tunnel5"

action 4.0 cli command "tunnel source Cellular0/2/0"

action 10.0 cli command "exit"


event manager applet TunnelChangeReverse
event track 70 state up
event timer watchdog time 10
action 1.0 cli command "enable"

action 2.0 cli command "configure term"

action 3.0 cli command "interface Tunnel5"

action 4.0 cli command "tunnel source Dialer1"

action 10.0 cli command "exit"

You config is correct' remove event timer and run 

Debug embedded event manager action cli

It does work without the timer if track 70 is up when I apply the config and then it goes down, EEM will activate.
However, if I apply the config and track 70 is already down, EEM does not activate.

With the timer, it checks every 10 seconds and activates TunnelChange regardless of if the track is up or down. I want it to only activate if the track is down if possible.

Is there a way to get it to run once its applied?

Or check if the track is down and then run, but if the track is up then do nothing?

Share debug please 
also please share the IP SLA and track status when the EEM not work 

There is an option to run the EEM policy based on any track transition, then use conditional if statements depending on up/down status of track.

 event track 1 state any maxrun 30
 action 015 puts "track state = $_track_state"
 action 020 if $_track_state eq "down"
 action 030 cli command <do something>
 action 40 end
....
 action 200 if $_track_state eq "up"
 action 210 cli command <do something>
 action 220 end

You will need to set the correct tunnel source when initially supplying the EEM config because it is triggered on a transition (up to down) or (down to up). 

rhallinan7387
Level 1
Level 1

One other trick with tracks I used years ago was stub-objects. Basically - you can define a track for example:

!
track 71 stub-object
 default-state down
!

Then - make a track list which does an 'OR' on the stub object and the object you're tracking - this can allow you to put some delay on what you're tracking - not sure what track 70 is doing - are you just tracking the interface state - or reachability via some SLA object? If so - just turning up might not be quite enough - you may want to give some time for routing processes to converge, etc...you can also add delay timers for going up. Timers are totally optional - I just liked that flexibility.

!
track 72 list boolean or
 object 70
 object 71
 delay down <X seconds> (optional)
!

You can use this track list going up and down in your EEM script (track on changes in state of 72 instead of 70). If you want to be able to kick off the monitoring by default on powerup (timers would probably use some adjusting - I was waiting a few minutes after bootup to kickoff the monitoring I was looking for) - this waits for 3 minutes after bootup and then turns the stub on, waits 5 seconds, then turns the stub off. If 70 is up the whole time - there is no change needed (OR will stay TRUE with one TRUE - and stay there). If 70 is actually down - then this will initiate a transition and the config change desired.

event manager applet kickoffstub
 event timer cron cron-entry "@reboot" maxrun 400
 action 01.0 wait 180
 action 02.0 cli command "enable"
 action 03.0 cli command "config t"
 action 04.0  cli command "track 71"
 action 05.0  cli command "default-state up"
 action 06.0 wait 5
 action 07.0  cli command "default-state down"
 action 08.0 cli command "end"

  When you deploy the EEM script - you can manually turn the stub object (71) on and off yourself (default-state up, then default-state down) - this will trigger the event going - as the 'OR' was first true - then changes to false. Further state changes on track 70 will be triggered by the EEM script tracking the track list (72).

One other thing to consider - what happens if someone saves the running configuration when the tracked 70 is down (on your cellular backup I assume) - but the device reloads for some reason and when it reloads the primary interface is up - but you are configured for cellular backup. You may want to add configuration to the EEM above which runs on startup to put the primary interface config in - and then you will still be able to handle the transitions.