Forum Discussion

Randy_Johnson_1's avatar
Randy_Johnson_1
Icon for Nimbostratus rankNimbostratus
Jan 05, 2010

Time stamp format -

Hello, group-

 

I'd like to insert a HTTP HEADER value that reflects the current time in GMT for a specific set of connections.

 

I'm comfortabloe in inserting the header, but am having difficulty in getting my timestamp.

 

 

I've used iRules like this:

 

when HTTP_REQUEST {

 

set http_request_time [clock clicks -milliseconds]

 

}

 

when HTTP_RESPONSE {

 

set http_response_time [ clock clicks -milliseconds ]

 

log 10.x.y.z local1.info "$request_log_line,\

 

[expr $http_response_time - $http_request_time]"

 

}

 

 

To log the elapsed time a connection took to a remote syslog, but I'm needing a little help in formatting my timestamp to GMT.

 

 

Anyone ?

 

 

Thanks !!!

2 Replies

  • Hi Randy,

     

    Here is a format for GMT

     

     

    [clock format [clock seconds] -gmt 1 ]

     

     

    It would look something like

     

     

    Tue Jan 05 23:00:00 GMT 2010

     

     

    I hope this helps

     

     

    Bhattman
  • You might also want to wrap the operands in the expr command in curly braces for better performance. See the expr man page's 'performance considerations' section for details:

     

     

     

    http://www.tcl.tk/man/tcl8.4/TclCmd/expr.htm

     

     

    Enclose expressions in braces for the best speed and the smallest storage requirements. This allows the Tcl bytecode compiler to generate the best code.

     

     

    As mentioned above, expressions are substituted twice: once by the Tcl parser and once by the expr command. For example, the commands

     

     

    set a 3

     

    set b {$a + 2}

     

    expr $b*4

     

     

    return 11, not a multiple of 4. This is because the Tcl parser will first substitute $a + 2 for the variable b, then the expr command will evaluate the expression $a + 2*4.

     

     

    Most expressions do not require a second round of substitutions. Either they are enclosed in braces or, if not, their variable and command substitutions yield numbers or strings that don't themselves require substitutions. However, because a few unbraced expressions need two rounds of substitutions, the bytecode compiler must emit additional instructions to handle this situation. The most expensive code is required for unbraced expressions that contain command substitutions. These expressions must be implemented by generating new code each time the expression is executed.

     

     

     

     

     
     log 10.x.y.z local1.info "$request_log_line,\ 
        [expr {[clock clicks -milliseconds] - $http_request_time}]" 
     

     

     

    Aaron