Forum Discussion
Peter_Reilly
Nimbostratus
Feb 08, 2005how to log dropped sessions
I would like to be able to use an iRule to log whenever a tcp session is dropped due to it reaching the tcp timeout value specified in a profile. Is there a mechanism to do this within iRules?
8 Replies
Sort By
- unRuleY_95363Historic F5 AccountThere is currently no command that returns the amount of idle time a connection has experienced. I will look into adding this to the IP::stats command.
when CLIENT_ACCEPTED { set prev_age 0 } when HTTP_REQUEST { set prev_age [IP::stats age] } when HTTP_RESPONSE { set prev_age [IP::stats age] } when CLIENT_CLOSED { if { [expr [IP::stats age] - $prev_age] > [IP::idle_timeout] } { log "Client: [IP::remote_addr]:[TCP::remote_port] timed out" } }
- Peter_Reilly
Nimbostratus
Thank you. Is there a way to include [HTTP:uri]? - rapmaster_c_127Historic F5 AccountSure, just set a variable to record the URI in the request:
when CLIENT_ACCEPTED { set prev_age 0 set req_uri "none" } when HTTP_REQUEST { set prev_age [IP::stats age] set req_uri [HTTP::uri] } when HTTP_RESPONSE { set prev_age [IP::stats age] } when CLIENT_CLOSED { if { [expr [IP::stats age] - $prev_age] > [IP::idle_timeout] } { log "Client: [IP::remote_addr]:[TCP::remote_port] requesting $req_uri timed out" } }
- Peter_Reilly
Nimbostratus
I get the following: - rapmaster_c_127Historic F5 AccountDid you put the
set req_uri "none"
- unRuleY_95363Historic F5 AccountAlso, I should point out that this method needs a little more work to make it absolutely complete. Basically, a large GET (or PUT) could potentially be confused with a timeout since the prev_age is only updated when the HTTP REQUEST or RESPONSE headers are parsed.
when CLIENT_ACCEPTED { set prev_age 0 TCP::collect set url "" } when CLIENT_DATA { set prev_age [IP::stats age] TCP::release TCP::collect } when HTTP_REQUEST { set url [HTTP::host][HTTP::uri] } when SERVER_CONNECTED { TCP::collect } when SERVER_DATA { set prev_age [IP::stats age] TCP::release TCP::collect } when CLIENT_CLOSED { if { [expr [IP::stats age] - $prev_age] > [IP::idle_timeout] } { log "Client: [IP::remote_addr]:[TCP::remote_port] - $url - timed out" } }
- John_Shin_10665
Nimbostratus
Is this really in seconds? I think it is in miliseconds. - Jeff_Silverman1
Nimbostratus
I used the code:
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