Forum Discussion

Katherine_G_106's avatar
Katherine_G_106
Icon for Nimbostratus rankNimbostratus
Nov 03, 2006

Variable or function to return name of current pool?

Good afternoon,

 

I have been writing a few simple iRules & a call to F5 support directed me to DevCentral. This looks like a super resource!

 

 

Now for my question: I am working on a generic iRule that will redirect to a maintenance site if no members of the pool are active. So far it looks like this:

 

 

when HTTP_REQUEST {

 

if { [active_members p_mypool_http ] < 1 } {

 

HTTP::redirect http://my.maint.page.com

 

}

 

}

 

 

I want to apply this iRule to all of my virtual servers, but I don't want to duplicate it for every virtual server just beacuse the name of the pool is explicitly referenced (p_mypool_http in this case).

 

 

How can I retrieve & assign the name of the virtual server's current pool to a variable so that I can write one rule for all virtual servers?

 

 

thanks!

 

Katherine

 

 

5 Replies

  • unRuleY_95363's avatar
    unRuleY_95363
    Historic F5 Account
    set curpool [LB::server pool]
    This will return the currently selected or attached pool. You can then test it with:
    if { [active_members $curpool] < 1} {

    HTH!
  • the LB::server value will return the name of the currently selected pool. So you could write a generic iRule like this

    when HTTP_REQUEST {
      if { [active_members [LB::server] ] < 1 } {
        HTTP::redirect http://my.maint.page.com
      }
    }

    I believe "[LB::server pool]" will return the pool name as well.

    -Joe