Forum Discussion
Matt_59095
Aug 18, 2011Nimbostratus
IP to DNS reverse lookup + Geo location? Delimitted format?
LTM 1500 9.4.8
Hi - we'd like to see where our website traffic is coming from, and by which companies. I'd prefer to log that into a format that i can read into a database table, so that i can create some friendly reports for management, if doable.
I'm sure there are irules like this already setup in the forum, and many different ways to go about this, but i'm not having any luck finding it.
Can someone point me in the right direction to an irule or forum topic? My irule skills are still beginner -> medium, so please be gentle.....
I have a winscp connection to the bigip, so i'm able to pull logs to my sql server.
- Matt_59095NimbostratusHi Aaron,
when CLIENT_ACCEPTED { Add some logic for determining which clients to log for if {[matchclass [IP::client_addr] equals $::filteredAddresses]}{ Get time for start of TCP connection in milleseconds set tcp_start_time [clock clicks -milliseconds] Log the start of a new TCP connection log "New TCP connection from [IP::client_addr]:[TCP::client_port] to [IP::local_addr]:[TCP::local_port]" } else { Disable all events for this rule and any other rule for this connection event disable all } } when HTTP_REQUEST { Get time for start of HTTP request set http_request_time [clock clicks -milliseconds] Log the start of a new HTTP request set LogString "Client [IP::client_addr]:[TCP::client_port] -> [HTTP::host][HTTP::uri]" log local0. "$LogString (request)" } when HTTP_RESPONSE { Received the response headers from the server. Log the pool name, IP and port, status and time delta log local0. "$LogString (response) - pool info: [LB::server] - status: [HTTP::status] (request/response\ delta: [expr [clock clicks -milliseconds] - $http_request_time]ms)" } when CLIENT_CLOSED { Log the end time of the TCP connection log "Closed TCP connection from [IP::client_addr]:[TCP::client_port] to [IP::local_addr]:[TCP::local_port]\ (open for: [expr [clock clicks -milliseconds] - $tcp_start_time]ms)" }
- hooleylistCirrostratusThat iRule shouldn't affect requests or response handling as it's just logging. Do you see an error in /var/log/ltm when you see the 324 error? If you take the iRule off the virtual server do you still see that error?
- Matt_59095NimbostratusAaron - if i enable the rule, the site does not come up, when i remove the irule, the site comes back up.
I'll check the log
- Matt_59095NimbostratusI'm finally getting back around to this - here is the error in the logs when i try and apply this irule:
- hooleylistCirrostratusDo you have a datagroup named exactly filteredAddresses? If not, the runtime error is expected as the datagroup referenced from the iRule doesn't exist.
- Matt_59095NimbostratusHi Aaron - no, i don't have a datagroup named filteredAddresses - do i need to make one, or modify the irule? Sorry, i'm a little clueless.
- hooleylistCirrostratusYou can create an address type data group in the GUI under Local Traffic >> iRules >> Data Group List tab >> Create. Select a type of 'Address' and then add the hosts and/or subnets you want to log for.
when CLIENT_ACCEPTED { Get time for start of TCP connection in milleseconds set tcp_start_time [clock clicks -milliseconds] Log the start of a new TCP connection log local0. "New TCP connection from [IP::client_addr]:[TCP::client_port] to [IP::local_addr]:[TCP::local_port]" } when HTTP_REQUEST { Get time for start of HTTP request set http_request_time [clock clicks -milliseconds] Log the start of a new HTTP request set LogString "Client [IP::client_addr]:[TCP::client_port] -> [HTTP::host][HTTP::uri]" log local0. "$LogString (request)" } when HTTP_RESPONSE { Received the response headers from the server. Log the pool name, IP and port, status and time delta log local0. "$LogString (response) - pool info: [LB::server] - status: [HTTP::status] (request/response\ delta: [expr {[clock clicks -milliseconds] - $http_request_time}]ms)" } when CLIENT_CLOSED { Log the end time of the TCP connection log "Closed TCP connection from [IP::client_addr]:[TCP::client_port] to [IP::local_addr]:[TCP::local_port]\ (open for: [expr {[clock clicks -milliseconds] - $tcp_start_time}]ms)" }
- Matt_59095NimbostratusAaron - that works, however i get an entry in the log for each page for the connection, and even just images on the page - so i get way too much log writing. I was trying to go with the filteredAddress irule because it seemed to figure out a way to only log one entry per client connection.
- Matt_59095NimbostratusHi Aaron - i know you're just helping people out of the goodness of your heart, and you have a ton of posts that you reply to - but do you have any other comments per the first irule i was trying to get working? Is there anyway to setup the filteredAddresses to be equal to the dynamic IP during the connection, so i can simply log one IP per "session", or is there another better way to do this?
- hooleylistCirrostratusHi Matt,
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