cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
236
Views
0
Helpful
3
Replies

time refernce for $_event_pub_sec

mariavelas
Level 1
Level 1

 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?

3 Replies 3

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"

Ruben Cocheno
Spotlight
Spotlight

@mariavelas 

Check this https://github.com/leonmflai/Cisco-EEM-Auto-Export

Tag me to follow up.
Please mark it as Helpful and/or Solution Accepted if that is the case. Thanks for making Engineering easy again.
Connect with me for more on Linkedin https://www.linkedin.com/in/rubencocheno/

Dan Frey
Cisco Employee
Cisco Employee

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