Forum Discussion
Kev_Pearce_1070
Nimbostratus
Aug 25, 2006Can I read the status of a pool in an iRule?
Hi,
I'm trying to write a very short simple iRule that says:
if pool1 is up then use pool1 else use pool2
But I can't find how to read the status of an pool in an iRule. ...
Colin_Walker_12
Aug 25, 2006Historic F5 Account
First of all, this should be something you can achieve without the use of an iRule. If you specify a default pool for the Virtual Server in question, and then select a fallback option that's appropriate, sending traffic to the secondary pool, you should be able to achieve this via normal configuration options which we always encourage.
If, for some reason, you do need to use an iRule, though, there are a couple of options for checking the status of the pool you're selecting in an iRule. The simplest would probably be to use the active_members command.
This command returns the number of active members in the specified pool. This would allow you to ensure that there was at least one member in the pool marked as "up" before sending traffic there.
You can read about the command in the iRules Wiki here: Click here
Included in the above link is this code snippet of a simple example rule using the command:
when HTTP_REQUEST {
if { [active_members http_pool] >= 2 } {
pool http_pool
}
}
This could be modified very slightly to meet your above requirements. Assuming pool1 is http_pool, and pool2 is http_pool2:
when HTTP_REQUEST {
if { [active_members http_pool] >= 1 } {
pool http_pool
} else {
pool http_pool2
}
}
HTH,
Colin
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
