05-27-2024 04:05 AM
Tyring to built-in $_event_pub_sec is defined as " The time, in seconds, at which the event was published to the EEM." based on this reference. How can I convert a current date/time to this reference frame?
05-27-2024 04:45 AM
Hello,
I used to use the script below for a 'real' rather than an epoch timestamp, maybe you can somehow incorporate that into what you need:
event manager applet test
event none
action 0.01 info type routername
action 1.01 cli command "enable"
action 1.02 cli command "show clock"
action 1.03 regexp "(2[0-3]|[01][0-9]):([0-6][0-9]):([0-6][0-9])" "$_cli_result" time hour minute second
action 1.04 puts "$time"
action 1.05 puts "$hour"
action 1.06 puts "$minute"
action 1.07 puts "$second"
action 1.11 cli command "show clock"
action 1.12 regexp "(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ([1-9]|0[1-9]|[1-2][0-9]|3[0-1]) (20[1-9][0-9])" "$_cli_result" time2 month day year
action 1.13 puts "$time2"
action 1.14 puts "$month"
action 1.15 puts "$day"
action 1.16 puts "$year"
action 2.01 cli command "configure terminal"
action 2.02 cli command "file prompt quiet"
action 2.03 cli command "do copy run ftp://10.0.0.10/$_info_routername-$year$month$day-$hour$minute$second.txt"
05-28-2024 01:06 AM
Check this https://github.com/leonmflai/Cisco-EEM-Auto-Export
06-01-2024 05:23 PM
This can be done by using EEM/TCL or in an applet by sourcing a TCL file to do the conversion. Here is an example using EEM/TCL.
::cisco::eem::event_register_none
# Execute these two CLI commands in global config mode:
# event manager directory user policy "flash:/"
# event manager policy <filename> type user
# Version 1.0
namespace import ::cisco::eem::*
namespace import ::cisco::lib::*
array set arr_einfo [event_reqinfo]
set event_pub_time $arr_einfo(event_pub_time)
set event_pub_time [expr int($event_pub_time)]
set result [clock format $event_pub_time]
puts "event_pub_time = $event_pub_time and converts to local time: $result"
client2#event manager run epoch2time.tcl
event_pub_time = 1717287649 and converts to local time: Sun Jun 02 00:20:49 UTC 2024
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