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

Scripting

tinhnho123
Level 2
Level 2

Wrong post. Sorry

5 Replies 5

event routing network x.x.x.x/y type add protocol BGP
try this event to detect add of prefix in your table 

balaji.bandi
Hall of Fame
Hall of Fame

Are you looking to check the Prefix in routing table then alert using email ?

check below example help you to build one and test it :

https://community.cisco.com/t5/network-management/setup-notification-when-new-route-get-put-in-routing-table/td-p/1849740

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

M02@rt37
VIP
VIP

Hello @tinhnho123 

 

Embedded Event Manager (EEM) script on a Cisco router to track/monitor the prefixes 10.19.99.0/24 and 10.20.100.0/24 and trigger an action if either or both disappear from the routing table, you can use the following EEM script:

event manager applet MonitorBgpPrefixes
event timer watchdog time 1800 maxrun 1790
action 1.0 syslog msg "Checking for the presence of prefixes in the BGP routing table..."
action 2.0 cli command "show ip route bgp | include 10.19.99.0/24"
action 3.0 regexp "10\.19\.99\.0" $_cli_result
action 4.0 set result1 "$_regexp_result"
action 5.0 cli command "show ip route bgp | include 10.20.100.0/24"
action 6.0 regexp "10\.20\.100\.0" $_cli_result
action 7.0 set result2 "$_regexp_result"
action 8.0 if $result1 eq "0" || $result2 eq "0"
action 8.1 syslog msg "One or both prefixes (10.19.99.0/24 and/or 10.20.100.0/24) are missing from the BGP routing table!"
action 8.2 syslog msg "Taking corrective action..."
action 8.3 cli command "your corrective action here" ;# Replace with your corrective action
action 8.4 end

In this script, the event timer watchdog is used to trigger the script at regular intervals (every 1800 seconds or 30 minutes, you can adjust it as needed). The script then checks for the presence of the specified prefixes in the BGP routing table using regular expressions. If either or both prefixes are not found, it logs a syslog message and takes a corrective action.

 

Best regards
.ı|ı.ı|ı. If This Helps, Please Rate .ı|ı.ı|ı.

Hello

When I entered this below and got the invalid input error:

ISR4451(config-applet)#action 8.0 if $result1 eq "0" || $result2 eq "0"
                                                                                 ^
% Invalid input detected at '^' marker.

ISR4451(config-applet)#

======

And below is the out put question marks.

ISR4451(config-applet)#action 8.0 if $result1 eq "0"?
WORD

ISR4451(config-applet)#action 8.0 if $result1 eq "0" ?
goto goto label
<cr> <cr>

ISR4451(config-applet)#action 8.0 if $result1 eq "0"

It doesn't support '||'; what do we need to replace it with?

I have SMTP server, how do we tell the script to email when one or two prefixes are missing? 

Thanks.

Action for what ?!?

You need event to detect add remove prefix from RIB then use action to send emails or syslog.

MHM

Review Cisco Networking products for a $25 gift card