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.
Anyone any ideas???
Cheers very much all
Kev/.
3 Replies
- Colin_Walker_12Historic F5 AccountFirst 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 - Kev_Pearce_1070
Nimbostratus
hi,
Cheers for the reply. Just what I needed. Just one other question... you said to do this in the normal config... how? I can see default and fallback persistance methods but only one (default) pool?
Cheers
Kev/. - Deb_Allen_18Historic F5 AccountHi Kev -
You can set a fallback URL for the virtual server, but it would be to a specific host and URI, rather than a reference to another pool.
Instead of a rule or fallback host, you could use priority grouping in your pool to use the preferred servers if available, otherwise use the fallback servers. To do that, define all of the servers in the default pool, assigning a higher priority to the preferred servers, and a lower priority to the fallback servers, setting "Priority Group Activation" to "Less than 1 available members"
HTH
/deb
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
