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

Creating array/vector of tracks, and then pick first one that's in UP state

Nadav
Level 7
Level 7

Hi everyone!

 

I have a setup of ASR-1001x's with up to date software.

 

Between them there are several point-to-point GRE tunnels, each one with an IP SLA configured, and a track associated to that IP SLA. The IP SLAs check parameters such as RTT and/or packet loss.

 

I need to create dynamic configurations when multiple tracks fail for a number of IP SLAs, and the dynamic configuration is based on the first available tunnel. So if I have 10 IP SLAs configured, and Tunnels 1-3, 6 and 7 are in a down track state, I'd need to pick Tunnel 4 as the first available GRE tunnel for which to create my dynamic configurations.

 

I am able to create the dynamic configurations assuming that I know which first available GRE tunnel number is available. For example if it's Tunnel 4, I know that I'd need to create configurations including a string composed of the IP "10.10.10.($firstAvailable*4+1)", or 10.10.10.17, which needs to be pushed into the configurations.

 

I'm unsure how to go about this in EEM, and I must admit that I have very little experience in EEM. Here is pseudo code which could possibly solve this businesss requirement:

 

1) tracks[10] = track1.state, track2.state, .... , track10.state

2) count = 0

3) for(i=1;i<=10;i++)

3.1) count = count + tracks[i]  (UP equals 1, DOWN equals 0)

4) if count <=8  (if two or more tracks are DOWN)

4.1) for(i=1;i<=10;i++)

4.1.1) if(tracks[i].state == UP)

4.1.1.1) $GREaddress = "10.10.10.(tracks[i].state*4+1)"

4.1.1.2) Create CLI configurations here...

4.1.1.3) Exit for loop  (for example, set "i" to 11)

 

Any ideas if this can be done, or perhaps even a simpler solution?

 

Thanks for your time, I realize this post may have been a bit on the long side

 

 

 

 

 

 

1 Accepted Solution

Accepted Solutions

Joe Clarke
Cisco Employee
Cisco Employee

I think you can do this with object tracking thresholds.  For example:

 

track 113 list threshold percentage

 threshold percentage up 81

 object 1

 object 2

 ...

 object 10

Then:

 

event manager environment num_tracks 10

!

event manager applet track-gre

 event track 113 state down

 action 001 cli command "enable"

 action 002 set count 1

 action 003 while $count le $num_tracks

 action 004  cli command "show track $count | inc State is"

 action 005  regexp "State is Up" "$_cli_result"

 action 006  if $_regexp_result eq 1

 action 007   set octet $count

 action 008   multiply $octet 4

 action 009   set octet $_result

 action 010   increment octet

 action 011   set gre_addr "10.10.10.$octet"

 action 012   DO CLI CONFIG HERE WITH $gre_addr

 action 013  end

 action 014  increment count

 action 015 end

View solution in original post

3 Replies 3

Joe Clarke
Cisco Employee
Cisco Employee

I think you can do this with object tracking thresholds.  For example:

 

track 113 list threshold percentage

 threshold percentage up 81

 object 1

 object 2

 ...

 object 10

Then:

 

event manager environment num_tracks 10

!

event manager applet track-gre

 event track 113 state down

 action 001 cli command "enable"

 action 002 set count 1

 action 003 while $count le $num_tracks

 action 004  cli command "show track $count | inc State is"

 action 005  regexp "State is Up" "$_cli_result"

 action 006  if $_regexp_result eq 1

 action 007   set octet $count

 action 008   multiply $octet 4

 action 009   set octet $_result

 action 010   increment octet

 action 011   set gre_addr "10.10.10.$octet"

 action 012   DO CLI CONFIG HERE WITH $gre_addr

 action 013  end

 action 014  increment count

 action 015 end

Thanks Joe,

 

I'll check it out a bit later, but the logic seems to be sound.

 

By the way, are you familiar with an in depth tutorial for EEM other than Cisco configuration guides?

I have given presentations on EEM at CiscoLive in the past (BRKNMS-2030), but that is the closest thing of which I'm aware.