Forum Discussion
eschurma_27945
Nimbostratus
Oct 24, 2007Retrieving time in milliseconds? (using v. 9.1.2)
I am trying to retrieve the current time, down to the number of milliseconds. I can't find any way to do this (I am using v9.1.2). If I use "clock milliseconds" I get the error
01070151:3: ...
JRahm
Admin
Oct 25, 2007Try this:
when CLIENT_ACCEPTED {
set secs [clock seconds]
set msec [clock clicks -milliseconds]
set base [expr { $secs * 1000 } ]
set fract [expr { $msec - $base }]
if { $fract >= 1000 } {
set diff [expr { $fract / 1000 }]
incr secs $diff
incr fract [expr { -1000 * $diff }]
}
log local0. "Timestamp with milliseconds is [clock format $secs -format {%H:%M:%S}].$fract"
}
My log entries with this code look like this:
Oct 25 08:16:47 tmm tmm[1541]: Rule logtime_rule : Timestamp with milliseconds is 08:16:47.399
Oct 25 08:16:49 tmm tmm[1541]: Rule logtime_rule : Timestamp with milliseconds is 08:16:49.575
Oct 25 08:16:49 tmm tmm[1541]: Rule logtime_rule : Timestamp with milliseconds is 08:16:49.582
Note that you really shouldn't use the clock command on production traffic unless your LTM is at least at version 9.2.
Modified from an example found here: http://wiki.tcl.tk/1035 Click here
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects