I have two Virtual Servers which each has public Ip address (let say):
124.124.124.124
125.125.125.125
Both of two IP address above are binded two one A record let say www.test.com. I want to monitor which IP address access one of those Virtual Servers, and how long an IP address accesses those Virtual Servers.
The first part can be done by applying the following sample iRule
when CLIENT_ACCEPTED {
log local0. "The Client Address is [IP::client_addr]
}
This will apply to the LTM log file every-time the VIP is accessed.
I am not exactly sure how to approach the second part of your request regarding duration. I am not even sure if it’s possible to report against duration against all connections.
Thanks for replying. Your iRules worked very well. There are some questions I want to ask
1. Could that iRules work without binded to a specific Virtual Server?
2. What I mean for the time connection is. Could an iRule track the time usage (for example internet user has connected to Virtual_Server_A for 1 hour) ?
3. What is the parameter in order iRules can appear the Virtual Server IP address?
You can track the start time of a TCP connection in CLIENT_ACCEPTED using ‘set start [clock clicks -milliseconds]’ and then calculate the delta in CLIENT_CLOSED using ‘[expr {[clock clicks -milliseconds] - $start}]’. Here is an example:
I think a good question to ask here is what are you trying to accomplish?? What kind of traffic is this? Do you have persistence enabled?
If you’re looking to track time spent on your web site/web app, some analytic tools on the webserver side might serve you better…
It sounds like this is something ongoing you want to monitor from the mention of logging.. but if it isn’t you could measure absolute time by running some TCP dumps and keying on the source address…