cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1429
Views
9
Helpful
8
Replies

First EEM script: make a backup of the config

gnijs
Level 4
Level 4

Hi all,

I am trying to write my first EEM script. The goal is that whenever someone change the config, a backup is written on flash.

I have the following:

file prompt quiet

event manager applet ConfigSync

event syslog occurs 1 pattern "\%SYS-5-CONFIG_I: Configured" maxrun 90

action 1.0 cli command "enable"

action 2.0 cli command "copy running bootflash:/latest-cfg"

but it doesn't seem to work. Any ideas ?

(the script is triggered, when i add a syslog action, i see the log, so that works)

1 Accepted Solution

Accepted Solutions

No, you won't create a loop since only one instance of the policy can run at one time.

I'm betting your problem is with command authorization. If you are using AAA command authorization, you may have to add:

event manager session cli username USER

Where USER is a username which is authorized to run the specified CLI commands.

View solution in original post

8 Replies 8

yjdabear
VIP Alumni
VIP Alumni

Seems to me "file prompt quiet" needs to be configured from within the eem applet itself:

event manager applet ConfigSync

event syslog occurs 1 pattern "\%SYS-5-CONFIG_I: Configured" maxrun 90

action 1.0 cli command "enable"

action 1.1 cli command "config t"

action 1.2 cli command "file prompt quiet"

action 1.3 cli command "end"

action 2.0 cli command "copy running bootflash:/latest-cfg"

action 3.0 cli command "config t"

action 3.1 cli command "no file prompt quiet"

action 3.2 cli command "end"

This is not necessary. As long as file prompt quiet is configured, the applet should work. Of course, unless you want file prompt quiet to be in effect constantly, doing it within the applet is preferred.

Seeing the output of "debug event manager action cli" would be helpful assuming file prompt quiet is actually configured.

That said, while EEM works for this task, you might want to check out the built-in config archive feature of IOS which offers a bit more features. See http://www.cisco.com/en/US/docs/ios/12_3t/12_3t7/feature/guide/gtrollbk.html#wp1100253 for more details.

1) i am familiar with the config archive feature. However, you can only specify one location. I want a copy on the local bootflash and also a copy in the flashcard inserted in the supervisor

2) i will try to get you the debug output

3) i did not want to implement the "file prompt quiet" inside the script, because look at the trigger: the script is triggered when you exit config mode. If i exit config mode within the script ("end action"), don't i create a recursive loop ??

mvg,

Geert

No, you won't create a loop since only one instance of the policy can run at one time.

I'm betting your problem is with command authorization. If you are using AAA command authorization, you may have to add:

event manager session cli username USER

Where USER is a username which is authorized to run the specified CLI commands.

Is the single-threadedness of EEM execution subject to change, or is it in place because of looping concerns like this?

You can configure it so multiple policies can run at the same time now. For example, to configure the default queue to allow two policies to run simultaneously:

event manager scheduler script thread class default number 2

The default is 1.

Thanks jclarke, that was it: AAA.

Adding the above command worked.

Yeah, you're right. It could be kludgily dealt with by turning on/off or adjusting the syslogging level along with "file prompt quiet", but that's not worth the trouble given it's unnecessary.

Here's an alternative approach using EEM tcl policy that seems easily adatable to do what you want near the end of this page:

http://www.cisco.com/en/US/products/ps6815/products_white_paper0900aecd803a4dad.shtml

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: