Forum Discussion
grabarz666
Nimbostratus
Aug 26, 2018iRule to cap traffic on VIP to 10Mbit/s with HTML OOS response if limit exceeded
Hi All,
I am looking at developing an iRule which will count a number of bytes incoming to VIP by using [IP::stats bytes in] event and based on the cap ("if" function) provide OOS HTML message ...
grabarz666
Nimbostratus
Aug 26, 2018I developed this iRule, it seems like counter now works properly. Can someone cast an eye for efficiency and whether iRule makes sense?
Thanks,
when HTTP_REQUEST {
set limit 10000000
set tbl "rate_limit"
set key [expr {[IP::stats bytes in]}]
Sum up values function
foreach element $key {
log local0. "Per request rate is: $element"
lappend IP [expr (0 + {$element})]
set sum [expr [join $IP +]]
log local0. "Sum of all requests is: $sum" }
Bandwidth cap condition
if {$sum >= $limit} {
HTTP::respond 200 content {
OOS page
Sorry, page is currently OOS, please refresh in a while...
}
table delete -subtable $tbl $key
log local0. "dropping..."
TCP::close
} else {
table set -subtable $tbl $key "new_tbl" 2 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