11-12-2021 09:46 AM
Hi All-
I am looking for a EEM script that can track OSPF route (a /24) in the routing table and bring up BGP neighbor (via no shut of BGP neighbor). If that /24 comes back into routing table then I need to perform BGP admin shut of the neighbor.
Action seems straight forward like below but I am not sure how to create a event for this.
event manager applet SHUT_DOWN_BGP
event syslog pattern " ROUTE 10.90.230.0/24 BEING LOST"
action 1.0 cli command "enable"
action 2.0 cli command "config t"
action 3.0 cli command "router bgp <AS>"
action 4.0 cli command "neighbor x.y.z.w shutdown"
action 5.0 cli command "neighbor x.y.z.w shutdown"
event manager applet NO_SHUT_BGP
event syslog pattern "ROUTE 10.90.230.0/24 BEING LEARNED "
action 1.0 cli command "enable"
action 2.0 cli command "config t"
action 3.0 cli command "router bgp <AS>"
action 4.0 cli command "no neighbor x.y.z.w shutdown"
action 5.0 cli command "no neighbor x.y.z.w shutdown"
Any help on this will be appreciated!
11-16-2021 07:55 AM - edited 11-16-2021 07:58 AM
Hello,
you could use EOT (Enhanced Object Tracking) to track the route, e.g.:
track 230 ip route 10.90.230.0/24 reachability
Now you could trigger your EEM applets by syslog messages like
%TRACKING-5-STATE: 230 ip route 10.90.230.0/24 reachability Up->Down
%TRACKING-5-STATE: 230 ip route 10.90.230.0/24 reachability Down->Up
But it's even easier to to use the track object state directly as the event trigger of your applets:
event manager applet SHUT_DOWN_BGP
event track 230 state down
(...)
!
event manager applet NO_SHUT_BGP
event track 230 state up
(...)
!
HTH
Rolf
11-16-2021 08:55 AM
Hi Rolf-
I am trying to track this route availability via OSPF only- above tracking configuration you have will track this route via any routing protocol and that will not work for me.
After some research I found there was a way to do this in IOS but however this configuration is not available in NX-OS Nexus 9500 I have running 10.1(1).
R01(config)# event manager applet ROUTE
R01(config-applet)# event routing network 192.168.254.33/32 type add protocol OSPF
So I am trying to find any alternate way.
Thanks,
Saurabh
11-16-2021 10:13 AM
Hello,
the scripts below should work. Actions 1,2, and 10 are optional (1 and 2 add a syslog message, and 10 sends an email):
event manager environment _email_from source_email@source_domain.com
event manager environment _email_to destination_email@destination_domain.com
event manager environment _email_server email.domain.com
!
event manager applet SHUT_DOWN_BGP
event routing network 10.90.230.0/24 type remove protocol OSPF
action 1.0 set msg "Route removed: Type: $_routing_type, Network: $_routing_network, Mask/Prefix: $_routing_mask, Protocol: $_routing_protocol, GW: $_routing_lastgateway, Intf: $_routing_lastinterface"
action 2.0 syslog msg "$msg"
action 3.0 cli command "enable"
action 4.0 info type routername
action 5.0 cli command "conf t"
action 6.0 cli command "router bgp <AS>"
action 7.0 cli command "neighbor x.y.z.w shutdown"
action 8.0 cli command "neighbor x.y.z.z shutdown"
action 9.0 cli command "end"
action 10.0 mail server "S_email_server" to "$_email_to" from "$_email_from" subject "OSPF route 10.90.230.0/24 removed on $_info_routername" body "$msg $_cli_result"
!
event manager applet NO_SHUT_BGP
event routing network 10.90.230.0/24 type add protocol OSPF
action 1.0 set msg "Route added: Type: $_routing_type, Network: $_routing_network, Mask/Prefix: $_routing_mask, Protocol: $_routing_protocol, GW: $_routing_lastgateway, Intf: $_routing_lastinterface"
action 2.0 syslog msg "$msg"
action 3.0 cli command "enable"
action 4.0 info type routername
action 5.0 cli command "conf t"
action 6.0 cli command "router bgp <AS>"
action 7.0 cli command "no neighbor x.y.z.w shutdown"
action 8.0 cli command "no neighbor x.y.z.z shutdown"
action 9.0 cli command "end"
action 10.0 mail server "S_email_server" to "$_email_to" from "$_email_from" subject "OSPF route 10.90.230.0/24 added on $_info_routername" body "$msg $_cli_result"
11-16-2021 10:24 AM
Hi Georg-
Unfortunately "event routing network" is not available command on the Nexus 9500 running 10.1(1). See below for available options:
event ?
cli Create a cli event specification
counter Create a counter event
fanabsent Create fanabsent event specification
fanbad Create fanbad event specification
fib FIB related event
gold Create a 'Diagnostic' event specification
internal-link-flap Create a 'internal-link-flap' event specification
memory Create memory thresholds event specification
module Create a 'module' event specification
module-failure Create a 'module-failure' event specification
neighbor-discovery Show CDP new neighbors
oir Create Online-Insertion-Removal event specification
policy-default Use the event in the system policy being overridden
poweroverbudget Create poweroverbudget event specification
snmp Create a 'snmp' event specification.
storm-control Create a storm control event specification
syslog Create a syslog event specification
sysmgr System manager related events
tag Event tag identifier
temperature Create temperature event specification
test Create a 'test' event specification
track Create a 'track' event specification
Software
BIOS: version 05.43
NXOS: version 10.1(1)
BIOS compile time: 11/22/2020
NXOS image file is: bootflash:///nxos.10.1.1.bin
NXOS compile time: 2/14/2021 15:00:00 [02/14/2021 17:41:40]
Hardware
cisco Nexus9500 C9504 (4 Slot) Chassis ("Supervisor Module")
Thanks,
Saurabh
11-16-2021 10:38 AM
Hello,
sorry about that, I did not see your answer to Rolf before I posted the EEM. The Nexus works a bit different, I'll see if I can figure out the correct syntax...
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