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 with no luck. Please let me know if this is worth pursuing or should I go back to the syslog-ng file.
I'm looking to log source and destination IP addresses along with the corresponding ports.
Thanks
- hoolio
Cirrostratus
Hi,when HTTP_REQUEST { set the URL here, log it on the response set url [HTTP::header Host][HTTP::uri] set vip [IP::local_addr]:[TCP::local_port] } when HTTP_RESPONSE { set client [IP::client_addr]:[TCP::client_port] set node [IP::server_addr]:[TCP::server_port] set nodeResp [HTTP::status] log connection info log local0.info "Client: $client -> VIP:$vip$url -> Node: $node with response $nodeResp" }
when CLIENT_ACCEPTED { set vip [IP::local_addr]:[TCP::local_port] } when SERVER_CONNECTED { set client "[IP::client_addr]:[TCP::client_port]" set node "[IP::server_addr]:[TCP::server_port]" } when CLIENT_CLOSED { log connection info log local0.info "Client $client -> VIP: $vip -> Node: $node" }
when CLIENT_ACCEPTED { set vip [IP::local_addr]:[UDP::local_port] } when SERVER_CONNECTED { set client "[IP::client_addr]:[UDP::client_port]" set node "[IP::server_addr]:[UDP::server_port]" } when CLIENT_CLOSED { log connection info log local0.info "Client $client -> VIP: $vip -> Node: $node" }
local0.info send logger entries to remote syslog server filter f_local0.info { facility(local0) and level(info) and match("logger"); }; destination can be a hostname or IP address destination d_logger { tcp("syslog.myhost.com" port (5000)); }; log { source(local); filter(f_local0.info); destination(d_logger); };
local0.* /var/log/ltm filter f_local0 { facility(local0) and level(info..emerg) and not match("logger"); }; destination d_ltm { file("/var/log/ltm" create_dirs(yes)); }; log { source(local); filter(f_local0); destination(d_ltm); };
- Tracy_Butler_90
Nimbostratus
Thanks for the info. I'm now receiving the logging that I needed. I've also discovered that when I'm sending this to a remote syslog server, it's not using the management interface. How do you designate which interface to use when making the connection to a remote syslog server? - JRahm
Admin
I don't think I can keep up, he's on fire! - hoolio
Cirrostratus
Hah... I have a long way to go to catch up to you guys. This forum is a great resource though and I get a lot from the posts here. - Randy_Johnson_1
Nimbostratus
Group - - hoolio
Cirrostratus
Here is an example of how you can use clock to get deltas between different points in the rule execution:when CLIENT_ACCEPTED { set tcp_start_time [clock clicks -milliseconds] } when HTTP_REQUEST { set http_request_time [clock clicks -milliseconds] } when HTTP_RESPONSE { set http_response_time [ clock clicks -milliseconds ] } when CLIENT_CLOSED { set tcp_end_time [ clock clicks -milliseconds ] log local0. "HTTP request/response difference: $http_response_time - $http_request_time = [expr $http_response_time - $http_request_time]" log local0. "Total connection time: $tcp_end_time - $tcp_start_time = [expr ($tcp_end_time - $tcp_start_time)]" }
- Randy_Johnson_1
Nimbostratus
Thanks, hoolio ! - hoolio
Cirrostratus
I suppose you could use the HTTP_RESPONSE_DATA event to trigger the end time for the HTTP request/response delta, but that would require using HTTP::collect to trigger the HTTP_RESPONSE_DATA event. HTTP::collect buffers the HTTP response content. I'm not sure how much load this would add. I would guess that this might increase the latency enough to impact the accuracy of the time measurements. - tungsten_112959
Nimbostratus
Hi Adrian, some question - hoolio
Cirrostratus
You should be able to add another set of statements (filter, destination and log) for "Blogger" events:local0.info /var/log/Blogger filter f_local0.info { facility(local0) and level(info) and match("http_B_logger"); }; destination d_Blogger { file("/var/log/Blogger" create_dirs(yes)); }; log { source(local); filter(f_local0.info); destination(d_Blogger); };
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