Forum Discussion
Robert_47833
Dec 07, 2011Altostratus
how to gather how many IPs hit the url and how many times
Hi,dear irule
I meet a new requirement recently
there is an URL: http://cjj.cjj.com/select
I wanna gather the stats :
how many IPs hit this url: such as ,10.0.0.1 ;10.0.0.2;10...
nitass
Dec 09, 2011Employee
this is counted for 60 seconds. please feel free to revise.
[root@ve1023:Active] config b virtual bar list
virtual bar {
snat automap
pool foo
destination 172.28.19.79:80
ip protocol 6
rules myrule
profiles {
http {}
tcp {}
}
}
[root@ve1023:Active] config b rule myrule list
rule myrule {
when CLIENT_ACCEPTED {
table set -subtable "iplist" [IP::client_addr] "ignored"
set reqno [table incr "reqs:[IP::client_addr]"]
table set -subtable "reqrate:[IP::client_addr]" $reqno "ignored" indefinite 60
}
when HTTP_REQUEST {
if {[string tolower [HTTP::uri]] equals "/stats"} {
set stats "ip,request number\n"
foreach ip [table keys -subtable "iplist"] {
append stats "$ip,[table keys -count -subtable "reqrate:$ip"]\n"
}
HTTP::respond 200 Content $stats
}
}
}
[root@ve1023:Active] config curl -i http://172.28.19.79/stats
HTTP/1.0 200 OK
Server: BigIP
Connection: Keep-Alive
Content-Length: 67
ip,request number
172.28.19.80,12
192.168.181.16,5
172.28.19.253,2
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