10-22-2018 07:01 AM
I need to be able to detect which route-map is applied to a BGP neighbor in an EEM script.
For example:
if route-map PRIMARY is configured on neighbor x, then run the command "standby 80 prio 160"
if route-map BACKUP is configured on neighbor x, however, then run the command "standby 80 prio 150"
regards,
Geert
10-22-2018 01:55 PM
Just trying to understand what is the use case here ?
This can be done manually also ? if 1 time replacement ?
10-23-2018 12:58 AM
Use case is simple: I have two routers: one is primary , one is secondary.
But operational team can decide to switch primary to secondary and vica versa at any time.
There is an EEM script running on the router, but its behavior depends on the router being primary or secondary.
So when the function changes (ie route-maps get swapped) the script needs to behave differently.
I know, when they switch the functions (route-maps) they can also adjust the script, but that is often forgotten, so why not let the script detect itself if it is running on the primary or secondary router ?
10-23-2018 01:22 AM
So you looking the EEM script to trigger based on failure scenarios ?
10-26-2018 01:28 AM
ok, so i have managed to get this working, thanks to some old Joe Clarke scripts :-)
The script itself detects if the router has a primary or standby function and adjusts HSRP accordingly.
the name of the route-maps are PRIMARY-MAP-OUT and BACKUP-MAP-OUT
event manager applet default-change
event routing network 0.0.0.0/0 type modify
action 0.1 set role "NONE"
action 0.2 cli command "show ip bgp neighbor 172.31.255.246 | i map for outgoing"
action 0.3 regexp ".*\s(.*)-MAP-OUT.*" "$_cli_result" match role
action 0.4 if $role eq "PRIMARY"
action 0.5 set hpriority "160"
action 0.6 else
action 0.7 set hpriority "150"
action 0.8 end
action 1.0 syslog msg "Default route changed to $_routing_lastgateway"
action 1.1 syslog msg "Detected role: $role"
action 2.0 if $_routing_lastgateway eq "172.31.255.2"
action 3.0 cli command "enable"
action 3.1 cli command "conf t"
action 3.2 cli command "interface Fa0/0"
action 3.3 cli command "standby 80 prio 50"
action 3.4 syslog msg "Adjusted HSRP priority (Fa0/0) to 50"
action 4.0 elseif $_routing_lastgateway eq 172.31.255.246
action 5.0 cli command "enable"
action 5.1 cli command "conf t"
action 5.2 cli command "interface Fa0/0"
action 5.3 cli command "standby 80 prio $hpriority"
action 5.4 syslog msg "Adjusted HSRP priority (Fa0/0) to $hpriority"
action 6.0 end
10-26-2018 04:27 AM
Glad all working..may it is time to test when the link fails and auto fail over with EEM.
Hope you have tested this i guess.
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