cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
5497
Views
10
Helpful
7
Replies

Save config to TFTP with EEM

daniel.dib
Level 7
Level 7

Hi.

I'm trying out the EEM for the first time. I have written an applet that looks like this:

event manager applet SaveConfigToTFTP

event cli pattern "write" sync no skip no

action 1 cli command "enable"

action 2 cli command "configure terminal"

action 3 cli command "file prompt quiet"

action 4 cli command "end"

action 5 cli command "copy running-config tftp://tftp-server/router-confg"

action 6 cli command "configure terminal"

action 7 cli command "no file prompt quiet"

action 8 cli command "end"

It seems to work the first time I use it but not after that(the trigger is write). When I debug I can see that the script is running everytime i use write but when I check on the TFTP-server the file is not there. If i do a wr n manually i can see the file on the TFTP-server. Any idea what I'm doing wrong? Thanks.

/Daniel

Daniel Dib
CCIE #37149
CCDE #20160011

Please rate helpful posts.
1 Accepted Solution

Accepted Solutions

The commands are always expanded before being passed to EEM. So, "write memory" will work just fine. To also match "copy running-config startup-config", you could try:

"(write memory|copy running-config startup-config)"

To set a timer, your applet could configure another, timer applet to run. For example:

action 010 cli command "event manager applet mytimer"

action 011 cli command "event timer countdown time 30"

action 012 cli command "action ..."

View solution in original post

7 Replies 7

Joe Clarke
Cisco Employee
Cisco Employee

What is the output of "debug event manager action cli" when running this policy?

Hi. This is the output. I have removed the real hostname and banner for privacy. I have added the output as an attachment because of the 4000 character limit.

Looks OK to me, however there is no file on TFTP with that timestamp.

/Daniel

Daniel Dib
CCIE #37149
CCDE #20160011

Please rate helpful posts.

The debug shows the transfer occurring. And the "!!" shows that the file was transferred successfully. Perhaps the TFTP server is not syncing the file to disk, or is renaming it internally. If this were a standard UNIX tftpd, a file router-confg would have to exist on the server with global write permissions. After the transfer, the files modify time would have been updated.

If you wanted to double-check IOS, you could get a sniffer trace of TFTP traffic (basically all UDP) between the device and the TFTP server at the time of the transfer. But based on this debug, and the applet itself, I think IOS is behaving correctly.

My applet seems to work indeed. Now another question. I tried to match several strings with event cli pattern. I want to match all commands that save to NVRAM and exclude wr n and copy run tftp. I want to match "wr", "write", "wr mem", "write mem", "write memory", "copy run start", "copy running-config startup-config" but not match "wr n" and "copy run tftp". Can i do this with regex? Is it possible to match a pattern and also set a timer?

/Daniel

Daniel Dib
CCIE #37149
CCDE #20160011

Please rate helpful posts.

The commands are always expanded before being passed to EEM. So, "write memory" will work just fine. To also match "copy running-config startup-config", you could try:

"(write memory|copy running-config startup-config)"

To set a timer, your applet could configure another, timer applet to run. For example:

action 010 cli command "event manager applet mytimer"

action 011 cli command "event timer countdown time 30"

action 012 cli command "action ..."

Nice, thank you. I eventually found a regex that worked. I used "(^write$|write memory|copy running-config startup-config)". Once again I greatly appreciate your help.

Daniel Dib
CCIE #37149
CCDE #20160011

Please rate helpful posts.

Hi Daniel,

I am trying to do the same thing but have not configured EEM before, I've used Kron scripts but the device I'm want to copy the config from does not have a supported IOS version for kron - 12.2

Please paste the EEM portion of your config so I know how to configure the switch to send its running config to a tftp server at a scheduled time (4am) once a week.

Many thanks,

Martha.

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: