01-12-2009 07:16 AM
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
Solved! Go to Solution.
01-13-2009 09:49 AM
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 ..."
01-12-2009 08:31 AM
What is the output of "debug event manager action cli" when running this policy?
01-12-2009 11:19 PM
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
01-12-2009 11:31 PM
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.
01-13-2009 05:31 AM
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
01-13-2009 09:49 AM
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 ..."
01-13-2009 11:36 AM
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.
04-30-2009 12:36 AM
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.
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