11-11-2022 12:05 PM
event manager applet 999_A trap authorization bypass
event track 999 state up
action 1.0 syslog priority warning msg "DECTK Kit KITNAME_01 is online."
The above configs work just like I want them to. I want to take this a bit further and create a text file that will append the same syslog message along with a timestamp. I have tried the below configs, but am having issues using variables and creating and appending to the file.
event manager applet 999_A trap authorization bypass
event track 999 state up
action 1.0 syslog priority warning msg "DECTK Kit KITNAME_01 is online."
action 1.1 file open lf flash:Report.txt w
action 1.2 file write lf $_event_pub_sec "DECTK Kit KITNAME_01 is online."
action 1.3 file close lf
I am having serious issues getting the action 1.2 line to work. When I do a show run, the configs come out as shown below:
event manager applet 999_A trap authorization bypass
event track 999 state up
action 1.0 syslog priority warning msg "DECTK Kit KITNAME_01 is online."
action 1.1 file open lf flash:Report.txt w
action 1.2 file write lf "DECTK Kit KITNAME_01 is online."
action 1.3 file close lf
The $_event_pub_sec variable does not stay in the configs and no matter how many time I run it, it just recreates the file and put the one line of "DECTK Kit KITNAME_01 is online." in with no timestamp. So it's not appending anything. Is there a better way to tackle what I am doing? Why am I having issues with the variable? My EEM version is 4.0, so I assume I have a all the features.
Thanks for any help that can be provided.
Solved! Go to Solution.
12-02-2022 07:06 AM
My solution:
event manager applet 999_A trap authorization bypass
event track 999 state up
action 1.0 cli command "enable"
action 1.1 syslog priority warnings msg ",DECTK Kit,DG4_ECK_03,is online."
action 1.2 file open fh flash:report.txt a+
action 1.3 file puts fh "\$_event_pub_time,DECTK Kit,DG4_ECK_03,is online."
action 1.4 file close fh
event manager applet 999_B trap authorization bypass
event track 999 state down
action 1.0 cli command "enable"
action 1.1 syslog priority warnings msg ",DECTK Kit,DG4_ECK_03,is offline."
action 1.2 file open fh flash:report.txt a+
action 1.3 file puts fh "\$_event_pub_time,DECTK Kit,DG4_ECK_03,is offline."
action 1.4 file close fh
I had an issue with the text in lines 1.3 not getting entered as a new line in my text file. I changed "write" to "puts" and that solved that issue. Also In order to use the variable correctly, I needed to put either single quotes around the variable, or a back slash in front of it. Everything works as it should now.
12-02-2022 07:06 AM
My solution:
event manager applet 999_A trap authorization bypass
event track 999 state up
action 1.0 cli command "enable"
action 1.1 syslog priority warnings msg ",DECTK Kit,DG4_ECK_03,is online."
action 1.2 file open fh flash:report.txt a+
action 1.3 file puts fh "\$_event_pub_time,DECTK Kit,DG4_ECK_03,is online."
action 1.4 file close fh
event manager applet 999_B trap authorization bypass
event track 999 state down
action 1.0 cli command "enable"
action 1.1 syslog priority warnings msg ",DECTK Kit,DG4_ECK_03,is offline."
action 1.2 file open fh flash:report.txt a+
action 1.3 file puts fh "\$_event_pub_time,DECTK Kit,DG4_ECK_03,is offline."
action 1.4 file close fh
I had an issue with the text in lines 1.3 not getting entered as a new line in my text file. I changed "write" to "puts" and that solved that issue. Also In order to use the variable correctly, I needed to put either single quotes around the variable, or a back slash in front of it. Everything works as it should now.
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