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

New to EEM, i wanna soft reset BGP when a prefix list is applied

Istvan kelemen
Level 1
Level 1

Hello,

 

This is my script:

 

event manager applet SOFTRESETBGP_IN
 event cli pattern "neighbor 10.0.0.2 prefix-list.* in" sync no skip no period 1
 action 1.0 cli command "do clear ip bgp 10.0.0.2 soft in"
 action 2.0 syslog msg "BGP PEERS SOFT RESETED IN"


event manager applet SOFTRESETBGP_OUT
 event cli pattern "neighbor 10.0.0.2 prefix-list.* out" sync no skip no period 1
 action 1.0 cli command "do clear ip bgp 10.0.0.2 soft out"
 action 2.0 syslog msg "BGP PEERS SOFT RESETED OUT"

 

When I issue the "neighbor 10.0.0.2 prefix-list A in" command it displays the pre-defined syslog msg, but the peer is not reseted.

 

Test:

 

R1(config-router)#do sh ip bgp
BGP table version is 7, local router ID is 10.0.0.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>i 2.2.2.2/32       10.0.0.2                 0    100      0 i
 *>i 22.22.22.22/32   10.0.0.2                 0    100      0 i
R1(config-router)#neighbor 10.0.0.2 prefix-list A in
R1(config-router)#
*Jan 10 13:58:57.663: %HA_EM-6-LOG: SOFTRESETBGP_IN: BGP PEERS SOFT RESETED IN
R1(config-router)#do sh ip bgp
BGP table version is 7, local router ID is 10.0.0.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>i 2.2.2.2/32       10.0.0.2                 0    100      0 i
 *>i 22.22.22.22/32   10.0.0.2                 0    100      0 i
R1(config-router)#

 

When I do manually clear the peer, the policy applies:


R1(config)#do clear ip bgp 10.0.0.2 soft in
R1(config)#do sh ip bgp
BGP table version is 8, local router ID is 10.0.0.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>i 2.2.2.2/32       10.0.0.2                 0    100      0 i
 

 

I have also tried to clear both direction without ".*"

 

event manager applet SOFTRESETBGP
 event cli pattern "neighbor 10.0.0.2 prefix-list" sync no skip no period 1
 action 1.0 cli command "do clear ip bgp 10.0.0.2 soft"
 action 2.0 syslog msg "BGP PEERS SOFT RESETED"

 

result is the same...

5 Replies 5

Istvan kelemen
Level 1
Level 1

Solved, debug shown "enable" is needed at the 1st place

Yep, and the "do" is not needed.  You're not in config mode at this point.

Hi Joeseph,

event cli pattern "neighbor 10.0.0.2 prefix-list.* in" sync no skip no period 1

I am also new to EEM. Can you please tell me what is the importance of sync and no skip and no period 1 keyword in this script?

CF

skip no means: execute the command (you can skip it)

sync no means: you have to execute the CLI command, then the EEM script runs

 

 

example to skip: 

 

R1#sh running | b event
event manager applet OSPF
 event cli pattern "clear ip ospf process" sync no skip yes period 1
!
end

R1#clear ip ospf process
R1#

 

 

without "skip"

R1#sh running | b event
R1#clear ip ospf process
Reset ALL OSPF processes? [no]: y
R1#

 

Istvan's explanation is correct.  In addition, the "period 1" statement is kind of useless here.  If you wanted to count the number of times the command executed in a given time window (or period), then you'd also have to add "occurs X".

 

In your case, I think you want the applet to run at the moment the command is executed.  So I would just drop the period keyword.