Forum Discussion

Stanley_87566's avatar
Stanley_87566
Icon for Nimbostratus rankNimbostratus
Apr 29, 2009

Log 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

  • 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
  • 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"]\]"

     

    }
  • 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's avatar
      Aurel
      Icon for Cirrus rankCirrus
      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's avatar
      Moshe_Hyzon_609
      Icon for Nimbostratus rankNimbostratus
      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