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

Can I track 2 events in one EEM Applet

I want to create an EEM script that changes some BGP network parameters when a remote site goes down, so Have an SLA to the public address of remote site. see below

track 1 ip sla 1 reachability
delay down 8 up 10
ip sla 1
icmp-echo 1<remote site public address
 timeout 4000
threshold 3000
frequency 30
ip sla schedule 1 life forever start-time now
 
track 2 ip sla 2 reachability
delay down 8 up 10
ip sla 2
icmp-echo 8.8.8.8 <Google public dns
 timeout 4000
threshold 3000
frequency 30
ip sla schedule 2 life forever start-time now
event manager applet Head-office-down
event track 1 state down
action 1.0 cli command "enable"
action 1.1 cli command “config t”
action 1.2 cli command “router bgp 64599”
action 1.3 cli command “address-family ipv4”
action 1.4 cli command “ network 121.200.231.128 mask 255.255.255.240”
action 1.5 cli command “network 150.207.153.224 mask 255.255.255.240”
action 1.6 cli command "int fa0/1"
action 1.7 cli command "no shut"
 
would work for remote site, but I also need to check that this site can still get to the Internet. Obviously I dont want this change to happen if the Internet is down locally at this site.
 Is there a simple fix for this?
regards
Richard
1 Accepted Solution

Accepted Solutions

Dan Frey
Cisco Employee
Cisco Employee

One option is to look for the state of track 2 inside of the EEM policy.  If track 1 goes down, and track 2 remains up, then make the change, otherwise no changes made.

event manager applet Head-office-down

event track 1 state down
trigger delay 30
action 010 cli command "enable"
action 020 cli command "show track 2 | inc Reachability"
action 030 regexp "Reachability is Up" "$_cli_result"
action 040 if _regexp_result eq "1"
action 050 cli command "conf t"
action 060 cli command "router bgp 64599"
action 065 cli command "address-family ipv4"
action 070 cli command "network 121.200.231.128 mask 255.255.255.240"
action 080 cli command "network 150.207.153.224 mask 255.255.255.240"
action 090 cli command "int fa0/1"
action 100 cli command "no shut"
action 110 end

View solution in original post

5 Replies 5

Dan Frey
Cisco Employee
Cisco Employee

One option is to look for the state of track 2 inside of the EEM policy.  If track 1 goes down, and track 2 remains up, then make the change, otherwise no changes made.

event manager applet Head-office-down

event track 1 state down
trigger delay 30
action 010 cli command "enable"
action 020 cli command "show track 2 | inc Reachability"
action 030 regexp "Reachability is Up" "$_cli_result"
action 040 if _regexp_result eq "1"
action 050 cli command "conf t"
action 060 cli command "router bgp 64599"
action 065 cli command "address-family ipv4"
action 070 cli command "network 121.200.231.128 mask 255.255.255.240"
action 080 cli command "network 150.207.153.224 mask 255.255.255.240"
action 090 cli command "int fa0/1"
action 100 cli command "no shut"
action 110 end

Daniel,

Only just got to try this script! does not work Event manager version is 3.20

I changed action 020 to cli command "show track 2 | inc Reachability is" because when you show track there is 2 lines with Reachability, so Thought it would narrow it down to just one line.

note the line action 040 if _regexp_result eq "1"  when I look at it in the config is

action 040 if _regexp_result eq 1 no inverted commas around the 1

here is the debug event manager action cli

Jun  8 21:45:28 AEST: %TRACKING-5-STATE: 1 ip sla 1 reachability Up->Down
Jun  8 21:45:33 AEST: %HA_EM-6-LOG: DMT-Internet-down : DEBUG(cli_lib) : : CTL : cli_open called.
Jun  8 21:45:33 AEST: %HA_EM-6-LOG: DMT-Internet-down : DEBUG(cli_lib) : : OUT : PMB-RT03>
Jun  8 21:45:33 AEST: %HA_EM-6-LOG: DMT-Internet-down : DEBUG(cli_lib) : : IN  : PMB-RT03>enable
Jun  8 21:45:33 AEST: %HA_EM-6-LOG: DMT-Internet-down : DEBUG(cli_lib) : : OUT : PMB-RT03#
Jun  8 21:45:33 AEST: %HA_EM-6-LOG: DMT-Internet-down : DEBUG(cli_lib) : : IN  : PMB-RT03#show track 2 | inc Reachability is
Jun  8 21:45:33 AEST: %HA_EM-6-LOG: DMT-Internet-down : DEBUG(cli_lib) : : OUT :   Reachability is Up
Jun  8 21:45:33 AEST: %HA_EM-6-LOG: DMT-Internet-down : DEBUG(cli_lib) : : OUT : PMB-RT03#
Jun  8 21:45:33 AEST: %HA_EM-6-LOG: DMT-Internet-down : DEBUG(cli_lib) : : CTL : cli_close called.
Jun  8 21:45:33 AEST: tty is now going through its death sequence

Hope you can help

Richard

should line  040 be if $ _regexp_result eq 1

Yes.  Well:

action 040 if $_regexp_result eq 1

Hi Daniel,

thanks for the response, I knew there must be a way of doing it.

I am just getting old and lazy!

thanks again

Richard