03-10-2016 10:58 PM
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
Solved! Go to Solution.
03-11-2016 09:14 AM
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
03-11-2016 09:14 AM
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
06-08-2016 05:04 AM
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
06-08-2016 05:11 AM
should line 040 be if $ _regexp_result eq 1
06-10-2016 07:50 AM
Yes. Well:
action 040 if $_regexp_result eq 1
03-11-2016 12:56 PM
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
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide