Forum Discussion
fun with irule
I am working on an excersise to insert random quotes into http headers. I have an irule that uses data groups and if your subnet is in the DG a header with a specific quote is inserted, if your IP subnet is not specified your get a default quote. I found an irule to randomize a bunch of characters but cant figure out how to randomize quotes.
perhaps a DG of quotes and then somehow time the time/sec to pull out a random quote. what I am trying to do is find a command or irule that functions like the fortune command in linux.
- JG
Cumulonimbus
You can have a DG of quotes keyed by numbers, and then generate a random number as the key. If you have, say, 10 quotes, you can get a random number like this:
expr {int(rand()*10)}
.
Slightly modified. You may try this:
Code
when HTTP_REQUEST {
set random [ expr {int(rand()*2)}] log local0. "random = $random" set member [class match -value $random equals dg] log local0. "member = $member" }
--
dg integer type:
0: quote0
1: quote1
Recent Discussions
Related Content
* 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