EEM action command, rewrite a file without asking for confirmation

Unanswered Question
Nov 17th, 2008

Hello, I'am checking the CPU threshold with EEM in a 6509 switch (12.2.18SXF9) with SUP-720-3B. When the CPU is over a preconfigured value, I want to copy the "show process cpu sorted" command to a file cpu.txt in the sup-bootflash, and if the file already exist,I want to rewrite it without asking me for confirmation. Can I do that ?

The following sample did not work, because always ask me for confirmation.

event manager applet Chequeo_CPU

event snmp oid 1.3.6.1.4.1.9.9.109.1.1.1.1.3.1 get-type exact entry-op ge entry-val 5 poll-interval 10

action 1.0 cli command "enable"

action 2.0 cli command "term exec prompt time"

action 3.0 cli command "show process cpu sorted | tee sup-bootflash:/cpu.txt"

action 4.0 snmp-trap strdata "Utilizacion CPU supero 5%, valor actual=$_snmp_oid_val%"

action 5.0 syslog msg "Utilizacion CPU supero 5%, valor actual=$_snmp_oid_val%"

!

end

Thanks a lot in advance.

Regards, Anacelia

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 0 (0 ratings)
Loading.
Joe Clarke Mon, 11/17/2008 - 08:19

Probably the easiest way to do this is by configuring "file prompt quiet". You can do this globably, or do this in your EEM policy:

action 2.1 cli command "config t"

action 2.2 cli command "file prompt quiet"

action 2.3 cli command "end"

action 3.1 cli command "config t"

action 3.2 cli command "no file prompt quiet"

action 3.3 cli command "end"

asarlo Mon, 11/17/2008 - 08:42

Thanks to answer me. I have another question, is there a difference between enabling "file prompt quiet" command from EEM policy than globally ?. My question is, because If I enable this command from the EEM policy, just at this time, somebody from another terminal session,execute "delete file" command before executing "no file prompt quiet" in this situation it sould not ask for confirmation. Isn't it.

Thanks!

Anacelia

Joe Clarke Mon, 11/17/2008 - 09:29

There is no difference between enabling it globally and enabling it from the policy. It's just the the command has a limited lifespan when configured from the policy. Delete commands will still prompt when "file prompt quiet" is enabled.

asarlo Mon, 11/17/2008 - 11:16

OK ! thanks a lot for your help.

Regards, Anacelia

asarlo Wed, 11/19/2008 - 09:28

Hello, I tried the way you suggest but didn't run.

I tried putting (file prompts quiet command globally and from the applet) this config :

event manager applet Chequeo_CPU

event snmp oid 1.3.6.1.4.1.9.9.109.1.1.1.1.3.1 get-type exact entry-op ge entry-val 1 poll-interval 10

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 "enable"

action 2.1 cli command "show process cpu sorted | tee disk0:cpu.txt"

action 2.2 snmp-trap strdata "Utilizacion CPU supero 1%, valor actual=$_snmp_oi

"

action 2.3 syslog msg "Utilizacion CPU supero 1%, valor actual=$_snmp_oid_val%

action 3.0 cli command "config t"

action 3.1 cli command "no file prompt quiet"

action 3.3 cli command "end"

Do you have any other suggestion ?

I enabled the "debug event manager action cli" command and I'am attaching also the debug log.

Thanks a lot!

Regards, Anacelia

Attachment: 
Joe Clarke Wed, 11/19/2008 - 09:34

I forgot, tee doesn't obey file prompt quiet in this release. Your choices are to either convert this policy to a Tcl policy which will allow you to write out the file using Tcl, or use a different operation. For example, tee the contents to a temporary file, then copy this file to the final file:

action 2.1 cli command "show process cpu sorted | tee disk0:cpu_tmp.txt

action 2.2 cli command "copy disk0:cpu_tmp.txt disk0:cpu.txt"

action 2.3 cli command "delete /force disk0:cpu_tmp.txt"

Actions

This Discussion