Also, 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.
So, to do this correctly, we really need to trigger off all data going through the connection and to do that, we need to use the CLIENT_DATA and SERVER_DATA events.
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"
}
}