10-22-2010 03:17 PM
I'm configuring EEM applet, example CPU High event. When it triggers the event, action is "show tech | redirect tftp://x.x.x.x/showtechoutput". The EEM event is working fine and triggered the show tech output into the tftp server. My question is, i'd like to add maybe date/time in the filename so it will not overwrite the file everytime there is a triggered event.
The EEM event variable i'm seeing in doc is "_event_pub_sec" but it won't work when i add after or before the filename. any idea?
thanks in advance ...
10-23-2010 02:54 PM
Adding $_event_pub_sec to the end of the filename should work:
action 1.0 "show tech | redirect tftp://x.x.x.x/showtech.$_event_pub_sec"
That said, TFTP is very particular about how files can be created. Typically, a TFTP server will require the file to exist before a remote host can copy to it. If the filename changes each second, this will not work. Using a protocol like FTP or SCP may work better.
08-25-2015 06:52 AM
Hi Gerard, did you able to solve this issue?
I am also looking for creating variable filename through eem. Although script below gives correct output from "puts" command, it does not create file:
action 20 cli command "sh clock"
action 30 set string "$_cli_result"
action 60 set filename "$_string_result.txt"
action 65 puts "$filename"
action 70 cli command "sh clock | append flash:file.$_filename"
08-25-2015 07:22 AM
In order to write to a file you need to enable the applet. You're missing:
action 10 cli command "enable"
Your variable is also wrong. You need:
action 70 cli command "show clock | append flash:file.$filename
Finally, not all filesystems support "append" so make sure you can run a similar command manually.
08-26-2015 03:59 AM
I did not include all actions for short post, we have "enable" command as first action.
In action 70 , $filename or $_filename does not create file with that name. However regex seems working, below commands worked as expected:
event manager applet test
event none
action 10 cli command "en"
action 20 cli command "sh clock"
action 21 regexp "([0-9]+).*" "$_cli_result" match hour
action 22 regexp ".*\[0-9]+):.*" "$_cli_result" match minute
action 23 regexp ".*\.([0-9]+).*" "$_cli_result" match msec
action 25 set result "TEST-IPT-GT-$hour$minute$msec"
action 30 set filename "$result.txt"
action 40 cli command "sh clock | append flash:$filename"
action 90 cli command "exit"
Thanks&Regards.
08-26-2015 06:50 AM
You don't need action 90. You should also enable "debug event manager action cli" and re-run your test. The output will show why the append command is failing.
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