cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1753
Views
0
Helpful
4
Replies

Script / Tracker repeat

sprocket10
Level 2
Level 2

I am running the below script which seems to be doing its job to a certain extent.

Once the script runs and the sim fails over, the tracker does not restart its timer until the tracker has changed to up.

What I am after is for the script to run as below, but to keep running the ping tests and if the tracker fails over but stays down for another 15 minutes to run again, and then again after another 15 minutes and keep repeating every 15 minutes until the tracker changes to up.

So the unit is swapping the sim every 15 minutes until it receives a signal. This is because one sim may run out of data allowance and the 2nd sim may have no signal.

 

 

-------

 

no track 2 ip sla 20 reachability
no ip sla 20
no event manager applet SimFailover

track 2 ip sla 20 reachability
 delay down 180 up 180
!
ip sla 20
 icmp-echo 8.8.8.8 source-interface Vlan1
 frequency 30
ip sla schedule 20 life forever start-time after 00:15:00
!
event manager applet SimFailover
 event track 2 state down
 action 1.0 syslog msg "No connectivity, failing over sim"
 action 0.1 cli command "enable"
 action 0.2 cli command "show cellular 0 security"
 action 0.3 regexp "Active SIM = ([0-9])" $_cli_result match sim
 action 0.4 if $sim eq 0
 action 0.5 cli command "cellular 0 lte sim activate slot 1"
 action 1.1 else
 action 1.2 cli command "cellular 0 lte sim activate slot 0"
 action 1.3 end

1 Accepted Solution

Accepted Solutions

Joe Clarke
Cisco Employee
Cisco Employee

What you should do is have your track down applet install another applet that actually does the swapping:

 

event manager environment q "

event manager environment cr $_cli_result

event manager environment s $sim

!

event manager applet SimFailover

 event track 2 state down

 action 001 cli command "enable"

 action 002 cli command "config t"

 action 003 cli command "event manager applet SimTimer"

 action 004 cli command "event timer watchdog time 900"

 action 005 cli command "action 0.1 cli command enable"

 action 006 cli command "action 0.2 cli command $q show cellular 0 security$q"

 action 007 cli command "action 0.3 regexp $q ?Active SIM = ([0-9])$q $cr match sim"

 action 008 cli command "action 0.4 if $s eq 0

 action 009 cli command "action 0.5 cli command $q cellular lte sim activate slot 1$q"

 action 010 cli command "action 1.0 syslog msg $q No connectivity, failing over sim$q"

 action 011 cli command "action 1.1 else"

 action 012 cli command "action 1.2 cli command $q cellular lte sim activate slot 0$q"

 action 013 cli command action 1.3 end"

 action 014 cli command "end"

!

event manager applet SimTrackUp

 event track 2 state up

 action 1.0 cli command "enable"

 action 2.0 cli command "config t"

 action 3.0 cli command "no event manager applet SimTimer"

 action 4.0 cli command "end"

View solution in original post

4 Replies 4

Joe Clarke
Cisco Employee
Cisco Employee

What you should do is have your track down applet install another applet that actually does the swapping:

 

event manager environment q "

event manager environment cr $_cli_result

event manager environment s $sim

!

event manager applet SimFailover

 event track 2 state down

 action 001 cli command "enable"

 action 002 cli command "config t"

 action 003 cli command "event manager applet SimTimer"

 action 004 cli command "event timer watchdog time 900"

 action 005 cli command "action 0.1 cli command enable"

 action 006 cli command "action 0.2 cli command $q show cellular 0 security$q"

 action 007 cli command "action 0.3 regexp $q ?Active SIM = ([0-9])$q $cr match sim"

 action 008 cli command "action 0.4 if $s eq 0

 action 009 cli command "action 0.5 cli command $q cellular lte sim activate slot 1$q"

 action 010 cli command "action 1.0 syslog msg $q No connectivity, failing over sim$q"

 action 011 cli command "action 1.1 else"

 action 012 cli command "action 1.2 cli command $q cellular lte sim activate slot 0$q"

 action 013 cli command action 1.3 end"

 action 014 cli command "end"

!

event manager applet SimTrackUp

 event track 2 state up

 action 1.0 cli command "enable"

 action 2.0 cli command "config t"

 action 3.0 cli command "no event manager applet SimTimer"

 action 4.0 cli command "end"

Hi

I am getting this error

%HA_EM-3-FMPD_UNKNOWN_ENV: fh_parse_var: could not find environment variable: sim

 

 

Please post the EEM config currently on the device as well as the full context around the error.  There should be a specific action label and policy name.

Hi

Its ok I simplified the commands as the router ignores the activate slot command that is for the currently live sim, so the below will always switch to the non live sim. Your applets above worked exactly as I needed, many thanks.

 

 action 005 cli command "action 0.1 cli command enable"
 action 006 cli command "action 0.2 cli command $q cellular 0 lte sim activate slot 1$q"
 action 007 cli command "action 0.3 cli command $q cellular 0 lte sim activate slot 0$q"