Forum Discussion
Tracy_Butler_90
Nimbostratus
Jul 06, 2006writing an irule to log all traffic
Need assistance with writing an irule to log all traffic flow. Support suggested that this should be done versus making changes to the syslog-ng file. I've tried making changes to syslog-ng file wit...
nitass
Employee
Oct 19, 2011HTTP::cookie is not valid in CLIENT_ACCEPTED.
HTTP::cookie wiki
http://devcentral.f5.com/wiki/iRules.HTTP__cookie.ashx
[root@iris:Active] config b virtual bar list
virtual bar {
snat automap
pool foo
destination 172.28.17.33:http
ip protocol tcp
rules myrule
profiles {
http {}
tcp {}
}
}
[root@iris:Active] config b rule myrule list
rule myrule {
when HTTP_REQUEST {
set flag 0
if {[HTTP::cookie exists "testcookie"]} {
set flag 1
set http_request_time [clock clicks -milliseconds]
set LogString "Client [IP::client_addr]:[TCP::client_port] -> [HTTP::host][HTTP::uri]"
}
}
when HTTP_RESPONSE {
if {$flag} {
log local0. "$LogString (response) - pool info: [LB::server] - status: [HTTP::status] (request/response delta: [expr [clock clicks -milliseconds] - $http_request_time]ms)"
}
}
}
GET / is not shown in log since testcookie has not been presented at the first request (it is set by pool member in the first response). log is written in /var/log/ltm file. if you want to write to another file, you can customize syslog-ng config.
[root@iris:Active] config tail -f /var/log/ltm
Oct 19 17:59:17 local/tmm info tmm[4601]: Rule myrule : Client 192.168.206.102:63807 -> 172.28.17.33/dog.gif (response) - pool info: foo 10.10.70.110 80 - status: 200 (request/response delta: 1ms)
Oct 19 17:59:17 local/tmm info tmm[4601]: Rule myrule : Client 192.168.206.102:63807 -> 172.28.17.33/favicon.ico (response) - pool info: foo 10.10.70.110 80 - status: 404 (request/response delta: 2ms)
Oct 19 17:59:17 local/tmm info tmm[4601]: Rule myrule : Client 192.168.206.102:63807 -> 172.28.17.33/favicon.ico (response) - pool info: foo 10.10.70.110 80 - status: 404 (request/response delta: 2ms)
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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