01-15-2024 08:40 AM
Hello
I working an organisation. There I am using EEM script to take backup when any user put copy running-config startup-config command in Nexus switch. But I am getting error % command blocked by event manager policy. Below is the script for reference
event manager applet BACKUP_CONFIG
Event cli match "copy running-config startup-config"
action 1.0 cli command "copy running-config tftp://tftp-server/backup_config.txt"
action 2.0 syslog msg Backup copied successfully
Kindly help here
01-15-2024 08:52 AM
Event cli pattern "copy running-config startup-config" sync YES <- Sync Yes use if you want this command to run
MHM
01-15-2024 09:06 AM
In Nexus 9k switch there is no that kind of command. Above mentioned cmd only there have. Can you suggest me how to bypass error with policy default. Earlier i read somewhere but I misplaced the post.
01-15-2024 09:11 AM
there is policy indeed and you can override it
check Link
thanks
MHM
01-15-2024 09:14 AM
Hi
Already tried, But there i cannot override it. Might be Some argument have to pass on it
01-15-2024 09:17 AM
event manager applet applet-name override system-policy
here you need to know if you apply system-policy and it name
did you check you all config about the system-policy ?
MHM
01-15-2024 09:35 AM
I think this statement answer your Q
01-15-2024 11:10 AM
In some Cisco Nexus N9K-NXOS-Releases, there is a workaround needed to execute "critical" commands.
* usually it works in EEM-Applets to
a) "source out" the original command to a "cli alias" and
b) call that "alias" from the applet
similar to that:
conf t
cli alias name wrbak copy running-config tftp://tftp-server/backup_config.txt
event manager applet BACKUP_CONFIG
no action 1.0
action 1.0 cli command "wrbak"
end
01-16-2024 09:33 AM
Hello
I tried but nothing works. But I have remembered somewhere i find the solution for this by adding policy default cmd but I missed that post
01-16-2024 09:35 AM
did you add event-default
to event ?
MHM
01-16-2024 09:36 AM
Yes.
01-16-2024 09:43 AM
can I see the EEM after you add event-default
MHM
01-16-2024 09:46 AM
event manager applet FTPBackup
event cli match "copy running-config startup-config"
action 0.3 syslog msg "Backup started."
action 0.5 cli command "enable"
action 1.0 cli command "copy running-config ftp://user:password@ourserver.com/path/$(SWITCHNAME)_$(TIMESTAMP) vrf default"
action 1.6 syslog msg "Backup ended."
action 2.0 event-default
01-18-2024 04:17 AM
I know - not what you might want, but would work out of the box:
* CLI-Alias with 2x commands instead of EEM:
cli alias name wr copy running-config startup-config ; copy running-config ftp://***FTPUSERNAME***:***FTPPASSWORD***@***FTPSERVERIP***/$(SWITCHNAME)-conf.$(TIMESTAMP) vrf default
10-23-2024 09:06 AM - edited 10-23-2024 09:39 AM
Try putting the "event-default" as your first action. That solved it for me.
Initially, I had this setup and received the "% Command blocked by event manager policy" error:
event manager applet Switch-Config-Backup
description "Backup Running Config To FTP Server"
event cli match "copy running-config startup-config"
action 1.0 cli run-script bootflash:Switch-Config-Backup
action 2.0 event-default
However, when I reversed the actions as follows, the "copy run start" command ran without errors:
event manager applet Switch-Config-Backup
description "Backup Running Config To FTP Server"
event cli match "copy running-config startup-config"
action 1.0 event-default
action 2.0 cli run-script bootflash:Switch-Config-Backup
My Switch-Config-Backup script contains the following line:
copy running-config ftp://<FTP-Username>:<FTP-Password>@<FTP-Server>/path/path/$(SWITCHNAME)/$(SWITCHNAME)---$(TIMESTAMP).txt vrf default
Hope this helps.
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