Forum Discussion
Stanley_87566
Nimbostratus
Apr 29, 2009Log millisecond by irule
I'm using irule to log down all load balance traffic via BIGIP. However I cannot record the millisecond for a very high traffic application. Is anybody know how record millisecond by irule on BIPIP?
Many thanks
5 Replies
- hoolio
Cirrostratus
You can use clock clicks -milleseconds (Click here) for deltas:
clock clicks ?-milliseconds?
Return a high-resolution time value as a system-dependent integer value. The unit of the value is system-dependent but should be the highest resolution clock available on the system such as a CPU cycle counter. If -milliseconds is specified, then the value is guaranteed to be of millisecond granularity. This value should only be used for the relative measurement of elapsed time.
Can you post an example of what you're trying and ltm logs showing the problem?
Aaron - Stanley_87566
Nimbostratus
Here's the example, thanks!
when LB_FAILED {
set info "client { [IP::client_addr]:[TCP::client_port] -> [clientside {IP::local_addr}]:[clientside {TCP::local_port}] }"
append info " Clock" {[clock format [clock seconds] -format "%d/%m/%Y:%H:%M:%S %z"]}
log local0. "$info - - \[[clock format [clock seconds] -format "%d/%m/%Y:%H:%M:%S %z"]\]"
}
when SERVER_CONNECTED {
set info "client { [IP::client_addr]:[TCP::client_port] -> [clientside {IP::local_addr}]:[clientside {TCP::local_port}] }"
append info " server { [IP::local_addr]:[TCP::local_port] -> [IP::server_addr]:[TCP::server_port] }"
append info " ethernet { [string range [LINK::lasthop] 0 16] -> [string range [LINK::nexthop] 0 16] tag [LINK::vlan_id] qos [LINK::qos] }"
log local0. "$info - - \[[clock format [clock seconds] -format "%d/%m/%Y:%H:%M:%S %z"]\]"
} - Stanley_87566
Nimbostratus
Thx Aaron, I can log milisecond now. Here's for your reference!
http://devcentral.f5.com/Default.aspx?tabid=53&forumid=5&postid=17943&view=topic
when LB_FAILED {
set info "client { [IP::client_addr]:[TCP::client_port] -> [clientside {IP::local_addr}]:[clientside {TCP::local_port}] }"
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 }]
}
append info " Clock" {[clock format [clock seconds] -format "%d/%m/%Y:%H:%M:%S.$fract %z"]}
log local0. "$info - - \[[clock format [clock seconds] -format "%d/%m/%Y:%H:%M:%S.$fract %z"]\]"
}
when SERVER_CONNECTED {
set info "client { [IP::client_addr]:[TCP::client_port] -> [clientside {IP::local_addr}]:[clientside {TCP::local_port}] }"
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 }]
}
append info " server { [IP::local_addr]:[TCP::local_port] -> [IP::server_addr]:[TCP::server_port] }"
append info " ethernet { [string range [LINK::lasthop] 0 16] -> [string range [LINK::nexthop] 0 16] tag [LINK::vlan_id] qos [LINK::qos] }"
log local0. "$info - - \[[clock format [clock seconds] -format "%d/%m/%Y:%H:%M:%S.$fract %z"]\]"
}- Aurel
Cirrus
Hi, this trick did offers milliseconds accuracy, but in my case also brings some issues. Sometimes the value is not 3 digits long but can be 2 or only 1. Maybe someone noticed the behaviour as well ? I understand that this may not be a problem for some cases, but it is for me of course. - Moshe_Hyzon_609
Nimbostratus
TO format milliseconds correctly, you can do something like: set fract [format "%03d" $fract] log local0. "$info - - \[[clock format $secs -format "%d/%m/%Y:%H:%M:%S.$fract %z"]\]" after all the math
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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