Forum Discussion
mpfeifer_63884
Nimbostratus
Nov 12, 2009redirect part of the traffic
Hi. This is my first post in this forum, I'm not sure if it is the right topic, but as it might involve complex iRuling, I give it a try to post it under "iRules".
We have a difficult i...
James_Quinby_46
Nov 12, 2009Historic F5 Account
Hmm. This is sort of working, but maybe one of the gurus can explain an odd bit of behavior I'm seeing.
when HTTP_REQUEST {
log local0. "rule starting, count is: [STATS::get counter "counter"] "
if {[STATS::get counter "counter"] == 40} {
reset the clock
STATS::set counter "counter" 0
log local0. "Clock was reset to 0."
}
if {[STATS::get counter "counter"] == 33} {
HTTP::redirect http://www.google.com
log local0. "redirect issued!"
}
STATS::incr counter "counter"
log local0. "Incremented the current count to: [STATS::get counter "counter"]"
}
I have a stats profile called "counter" with a single field in it, also called "counter". What I see in the logs sort of indicates that the number isn't being incremented correctly - a CMP issue, perhaps?
Nov 12 14:55:35 v10bigip tmm tmm[5000]: Rule redirect_some_percent : Incremented the current count to: 1
Nov 12 14:55:39 v10bigip tmm1 tmm1[5001]: Rule redirect_some_percent : rule starting, count is: 40
Nov 12 14:55:39 v10bigip tmm1 tmm1[5001]: Rule redirect_some_percent : Clock was reset to 0.
Nov 12 14:55:39 v10bigip tmm1 tmm1[5001]: Rule redirect_some_percent : Incremented the current count to: 1
Nov 12 14:55:47 v10bigip tmm tmm[5000]: Rule redirect_some_percent : rule starting, count is: 1
Nov 12 14:55:47 v10bigip tmm tmm[5000]: Rule redirect_some_percent : Incremented the current count to: 2
Nov 12 14:55:50 v10bigip tmm1 tmm1[5001]: Rule redirect_some_percent : rule starting, count is: 1
Nov 12 14:55:50 v10bigip tmm1 tmm1[5001]: Rule redirect_some_percent : Incremented the current count to: 2
At 33, the request to google was issued as expected.
Notice that it stayed 1 for 2 iterations there. In the final rule, we'd want to basically roll through a 0-99 count, then issue the redirect 3 times, at 33, 66 and 99 for example. This is sort of a quick proof of concept, but it's pretty close. It's possible that it could be tightened up considerably, speed- and efficiency-wise.
JQ
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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