Forum Discussion
iRule logic to use multiple pools to force GTM failover on VIP
I have a VIP that has no status because the pool that it uses is determined by a policy. To add state to the VIP I've added the following iRule:
when HTTP_REQUEST {
if { [active_members pool1] == 0 } {
# log
}
The VIP now shows a status of green (UP). When I disable the pool members in pool1, the VIP goes down and the GTM routes traffic to another data center.
Since I have a VIP that has multiple pools, I need to fail the VIP if any one pool member is down.
I've tried these examples:
if { [active_members pool1] == 0 } {
# log
}
elseif { [active_members pool2] == 0 } {
# log
}
elseif { [active_members pool3] == 0 } {
# log
}
elseif { [active_members pool4] == 0 } {
# log
}
}
and...
when HTTP_REQUEST {
if { [active_members pool1] == 0 or [active_members pool2] == 0 or [active_members pool3] == 0 }r
# log
}
}
When I take any one pool down, the VIP remains up.
Any suggestions?
Thanks
Kevin
Hi Kevin,
- Create an iRule:
ltm rule irule_poolstatus { when HTTP_REQUEST { if { [active_members pool1] == 0 || [active_members pool2] == 0 || [active_members pool3] == 0 || [active_members pool4] == 0} { HTTP::respond 200 content "down" } else { HTTP::respond 200 content "up" } } }
- Create a Virtual Server with IP x.y.z.t and bind the iRule:
ltm virtual vs_poolstatus { destination 1.2.3.4:http ip-protocol tcp mask 255.255.255.255 profiles { http { } tcp { } } rules { irule_poolstatus } serverssl-use-sni disabled source 0.0.0.0/0 source-address-translation { type automap } translate-address enabled translate-port enabled }
- Create a monitor with receive string:
ltm monitor http monitor_status { adaptive disabled defaults-from http interval 5 ip-dscp 0 recv up recv-disable none send "GET /\r\n" time-until-up 0 timeout 16 }
- Create a pool, add the virtual server IP address as pool member and bind the monitor:
ltm pool pool_status { members { 1.2.3.4:http { address 1.2.3.4 session monitor-enabled } } monitor monitor_status }
- Create second iRule:
when HTTP_REQUEST { if { [active_members pool_status] == 0} { # log } }
- Add the iRule to main virtual server
first iRule and virtual server: for "up/down response"
pool and monitor: for receive a request to the virtual server and to see the "up/down" status
I couldn't find a shorter solution.
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