Forum Discussion

Ganesh_Garg's avatar
Ganesh_Garg
Icon for Nimbostratus rankNimbostratus
Jul 21, 2014

Irule to LOG traffic with server responses on version 11.4.x

I need an Irule to log traffic with server response on version 11.4.x, I have one for version 10.x but I believe there are some syntax changes in version 10 and 11. Please find below Irule: -

 

1. For HTTP: -

when CLIENT_ACCEPTED { Get time for start of TCP connection in milleseconds set tcp_start_time [clock clicks -milliseconds] Log the start of a new TCP connection log local0. "New TCP connection from [IP::client_addr]:[TCP::client_port] to [IP::local_addr]:[TCP::local_port]" }

 

when HTTP_REQUEST { Get time for start of HTTP request set http_request_time [clock clicks -milliseconds] Log the start of a new HTTP request set LogString "Client [IP::client_addr]:[TCP::client_port] -> [HTTP::host][HTTP::uri]" log local0. "$LogString (request)" }

 

when LB_SELECTED { log local0. "Client [IP::client_addr]:[TCP::client_port]: Selected [LB::server]" }

 

when LB_FAILED { log local0. "Client [IP::client_addr]:[TCP::client_port]: Failed to [LB::server]" }

 

when SERVER_CONNECTED { log local0. "Client [IP::client_addr]:[TCP::client_port]: Connected to [IP::server_addr]:[TCP::server_port]" }

 

when HTTP_RESPONSE { Received the response headers from the server. Log the pool name, IP and port, status and time delta log local0. "$LogString (response) - pool info: [LB::server] - status: [HTTP::status] (request/response delta: [expr {[clock clicks -milliseconds] - $http_request_time}] ms)" }

 

when CLIENT_CLOSED { Log the end time of the TCP connection log local0. "Closed TCP connection from [IP::client_addr]:[TCP::client_port] to [IP::local_addr]:[TCP::local_port] (open for: [expr {[clock clicks -milliseconds] - $tcp_start_time}] ms)" }

 

2. For TCP: -

when CLIENT_ACCEPTED { Get time for start of TCP connection in milleseconds set tcp_start_time [clock clicks -milliseconds] Log the start of a new TCP connection log local0. "New TCP connection from [IP::client_addr]:[TCP::client_port] to [IP::local_addr]:[TCP::local_port]" }

 

when LB_SELECTED { log local0. "Client [IP::client_addr]:[TCP::client_port]: Selected [LB::server]" }

 

when LB_FAILED { log local0. "Client [IP::client_addr]:[TCP::client_port]: Failed to [LB::server]" }

 

when SERVER_CONNECTED { log local0. "Client [IP::client_addr]:[TCP::client_port]: Connected to [IP::server_addr]:[TCP::server_port]" }

 

when CLIENT_CLOSED { Log the end time of the TCP connection log local0. "Closed TCP connection from [IP::client_addr]:[TCP::client_port] to [IP::local_addr]:[TCP::local_port] (open for: [expr {[clock clicks -milliseconds] - $tcp_start_time}] ms)" }

 

Can anyone please help me out in converting the syntax compatible for 11.4.x

 

1 Reply

  • Hi Ganesh,

     

    which of your commands is throughing the syntax error and/or can you provide the error message? You are using only standard/basic TCL commands, which should also be valid in version 11.x

     

    Ciao Stefan :)