Forum Discussion

Siddarth_84779's avatar
Siddarth_84779
Icon for Nimbostratus rankNimbostratus
Jan 28, 2011

iRule for maintenance page

Hi guys,

 

 

I want to write an irule for maintenance page such that the single iRule can be applied to multiple VS. Presently we are using the below irule

 

when HTTP_REQUEST {

 

if {[active_members pool A] < 1}{

 

HTTP::redirect } }

 

 

Problem here is we have to change the pool name when applying irule to different VS.

 

 

Is there any command in irule to get the default pool of the vs.

 

 

Thanks in advance.

 

 

Regards,

 

Sid

 

 

 

10 Replies

  • You can use "LB::server pool" from the CLIENT_ACCEPTED event.

    
    when CLIENT_ACCEPTED {
       set dpool [LB::server pool] }
    
    when HTTP_REQUEST {
       if { [active_members pool $dpool] < 1 } {
          HTTP::redirect "http://maintenancepage.html" }
     }
    
  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    Nice one Chris. Very simple yet quite handy. You could even set up a class that stores individual maintenance URLs for each possible end pool and still use a single iRule across all your Virtuals to deploy pool specific maintenance pages.

     

     

    I like it.

     

     

    Colin
  • wow!! exactly what i wanted.

     

     

    Thanks a lot chris.. Let me try using classes as colin suggested.

     

     

     

    Regards,

     

    Sid
  • You could technically evaluate the default pool directly in the HTTP_REQUEST event:

    if { [active_members [LB::server pool]] < 1 } {
        [do something]
    }
    

    But you'll likely find the difference in memory footprint negligible.

  • JG's avatar
    JG
    Icon for Cumulonimbus rankCumulonimbus

    I need an inline (no HTTP redirect) long maintenance page for a particular website, and I want to get around the bug in "LB_FAILED" (ID 222034). Below is a cut-down version of my code:

     

    when HTTP_REQUEST {
        switch -- [string tolower [HTTP::host]] {
            "www.example.com" {
                pool www.example.com_pool
                set selected_server [LB::server addr]
                if {$selected_server == ""} {
                     If there are no members available, generate a long Maintenance Page
                    HTTP::respond ...
                }
            }
            "www.example2.com" {
                pool www.example2.com_pool
                ...
            }
        }
    }

    Will anybody comment on whether this will work, or if there is anything not right here, or if there is a better way to achieve the same effect?

     

  • DenisG_22372's avatar
    DenisG_22372
    Historic F5 Account

    I think a better way would be to do a check if there are pool members before you select the pool. I would look at the example:

    when HTTP_REQUEST {
    switch -- [string tolower [HTTP::host]] {
    "www.example.com" {
        if { [active_members www.example2.com_pool] < 1 } {
             If there are no members available, generate a long Maintenance Page
            HTTP::respond ...
        } else {
        pool www.example.com_pool
    }
    "www.example2.com" {
        pool www.example2.com_pool
        ...
        }
    }
    

    }

    Hopefully this will get you started to getting this working

    • JG's avatar
      JG
      Icon for Cumulonimbus rankCumulonimbus
      This is certainly better! I cut-and-pasted the code from two of my other servers each of which had very different requirements and different strategies. In one I did not have a default pool configured, and in the other I did not want to specify the name of the pool. I should not consider either here. Thanks!
  • How do I create an iRule on the GTM that redirects to a maintenance page, if all Virtual Servers in a pool are not available?

  • Understand of course that GTM does DNS, and you're looking for an HTTP redirect. Two different things. You can certainly create an LTM iRule to redirect to a maintenance page if pool members are down. But a DNS request isn't going to produce an HTTP response.

  • Thanks Kevin for your response. How about a maintenance page in case both virtual servers are available in a Wide IP pool? This particular application has to be in an active standby state. If one of the virtual servers are not available I can setup the maintenance page at the LTM level. I also want a maintenance page in case both virtual servers are available in a WIP pool.