Hello,
On 03/11/2009 06:21 PM, Mik Cheez wrote:
I'm hoping to store several gateway IP's in a hash table using HTable, then grab one of them randomly. Does anyone have a recommendation as to how this can be done, or perhaps a better way to do it? I chose HTable because a) I want to reload the values every x minutes and b) I'm using it for other purposes.
add in htable several keys: - "gateway[x]" - where x is 0 to the number of gateways - "gateway::size" - where to store the number of gateways
Then use the cfgutils module and get your gateway with: $var(x) = $RANDOM % $sht(gateway::size); $var(gwip) = $sht(gateway[$var(x)]);
FYI - although you may know - dispatcher has an algorithm for random selection of destination.
Cheers, Daniel