Forum Discussion

Andrew_Smith_16's avatar
Andrew_Smith_16
Icon for Nimbostratus rankNimbostratus
Jun 15, 2016

iRule with pool status and maintenance page

I have several iRules that currently have 20+ switch elements that matches on a specific uri which takes you to a particular pool. I now need to display a maintenance page if there are no members in ...
  • Yann_Desmarest_'s avatar
    Jun 15, 2016

    Hi,

    Here is an irule example that do the same as your own irule :

    when HTTP_REQUEST {
        if { [active_members pool1] <1 or [active_members pool2] <1 or [active_members pool3] <1} {
            if { [URI::basename [HTTP::uri]] eq "logo.jpg" } {
                HTTP::respond 200 content [ifile get logo.gif] "Content-Type" "image/gif"
            } else {
                HTTP::respond 200 content [ifile get error.html] "Content-Type" "text/html"
            }
        } else {
            switch -glob [HTTP::uri] {
                "/foo1*"  { pool pool1 }
                "/foo2*" { pool pool2 }
                "/foo3*" { pool pool3 }     
            }       
        }           
    }