cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements

489
Views
0
Helpful
5
Replies
Beginner

N9K unable to execute EEM script on reboot consistently

I was wondering whether anyone has some information on how to execute an EEM script on a switch reload before the ports can start forwarding. Effectively the problem is the host ports start forwarding before the bgp session is established and I would like the script to shut down the ports immediately before then can start forwarding. Only when the BGP session is established the host ports can be unshut.

 

Any advise on this please?

 

event manager applet interface_Shutdown

event timer cron cron-entry "@reboot"

action 1.0 cli command "config t"

action 2.0 cli command "interface eth1/1-10"

action 3.0 cli command "shutdown"

action 4.0 cli command "end"

 

The above script is inconsistent and looking at the actin-cli-logs 9/10 times it says system unable to parse commands.

 

Is there a bug on the 9k running i 7.0.3.i7(6)

1 ACCEPTED SOLUTION

Accepted Solutions
Hall of Fame Cisco Employee

Re: N9K unable to execute EEM script on reboot consistently

This should be fine.  You might consider removing the nested applet from the config after it's done to prevent it being saved to startup.

5 REPLIES 5
Hall of Fame Cisco Employee

Re: N9K unable to execute EEM script on reboot consistently

Likely you're seeing a race condition.  Ultimately, there may not be a reliable way to do what you want and do it soon enough in the boot process.  But you could try looking for a syslog message that occurs after boot that would give the switch enough time to allow config changes, and use this instead of the cron timer.  Alternatively, you could try executing a Python script that can call "time.sleep(N)" where N is a number of seconds to sleep before trying to execute the same config commands.   Something like:

 

import time

import cli



time.sleep(3)

cli.clip('config t ; int e1/1-10 ; shut')
Beginner

Re: N9K unable to execute EEM script on reboot consistently

thanks @Joe Clarke 

 

I've ended up using

 

event manager applet track-up
event syslog pattern "%ASCII-CFG-2-CONF_CONTROL: System ready"
action 1.0 cli conf
action 2 cli event manager applet track-timer
action 3 cli event timer countdown time 10
action 4 cli action 1.0 cli config
action 5 cli action 2.0 cli int eth1/1-10
action 6 cli action 3.0 cli shut
action 7 cli action 4.0 cli end

 

seems to do the job and 10 seconds is enough to trigger the disable.. still gotta burn test this but looks like i have a way forward. Please let me know if this can be improved or if there's any flaws in the above.

Hall of Fame Cisco Employee

Re: N9K unable to execute EEM script on reboot consistently

This should be fine.  You might consider removing the nested applet from the config after it's done to prevent it being saved to startup.

Highlighted
Beginner

Re: N9K unable to execute EEM script on reboot consistently

Hi Joe.

 

Would there be any harm if it was written to the startup config. I don't see what would trigger it to execute.

Beginner

Re: N9K unable to execute EEM script on reboot consistently

Ah i just got what you meant on this.

 

https://community.cisco.com/t5/networking-documents/how-to-introduce-large-delays-in-eem-policies/ta-p/3161702

 

Yes, I'll do so and thanks again for your help with this.

CreatePlease to create content
Content for Community-Ad
July's Community Spotlight Awards