Forum Discussion
iRule to disable a pool to new connections
Sure thing, though after thinking about it I've had a slight change of heart. The code below should do what you need:
when RULE_INIT {
set static::START_OFF_TIME "09:30 AM"
set static::END_OFF_TIME "10:00 AM"
set static::DOWN_POOL "local-pool"
set static::DOWN_MEMBERS [list "10.70.0.1 80" "10.70.0.2 80"]
}
when CLIENT_ACCEPTED {
set start_off_time [clock scan $static::START_OFF_TIME]
set end_off_time [clock scan $static::END_OFF_TIME]
set now [clock seconds]
if { ( [expr $now > $start_off_time] ) and ( [expr $now < $end_off_time] ) } {
foreach x $static::DOWN_MEMBERS {
LB::down pool $static::DOWN_POOL member [lindex $x 0] [lindex $x 1]
}
}
}The idea is that, at the given time period, selected members of the pool are marked down in the CLIENT_ACCEPTED event. This prevents them from being selected in the LB decision. I've added two new static variables:
set static::DOWN_POOL "local-pool"This is the name of the pool, though you could also derive this with [LB::server pool] in the CLIENT_ACCEPTED event.
set static::DOWN_MEMBERS [list "10.70.0.1 80" "10.70.0.2 80"]This is a list (IP and port) of each pool member to take down at the given time period. The CLIENT_ACCEPTED event loops through this list, removing these members from pool selection. You could still use the USER_ALERT method, but it becomes a bit more complex as you also have to manage bringing the members back up - an event that wouldn't be triggered until someone made a request.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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