Forum Discussion
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