Forum Discussion

VictorC's avatar
VictorC
Icon for Nimbostratus rankNimbostratus
Oct 24, 2017

Can I add active member check to pool switch iRule?

Hello all, I have a request from a user where they would like a URI redirection to a separate 3rd host. The current pool has 2 hosts. The condition is if it matches the URI redirection, but the 3rd host is down, then go back to the original pool of 2 hosts. Is that possible? So far my iRule looks like this but I cannot figure out the 2nd requirement they need. Any help is appreciated. If there is a better way to do this otherwise, please let me know. Thanks!

ltm rule myrule {
  when HTTP_REQUEST {
    switch -glob [HTTP::uri] {
    "/myuri/abc*"  { pool myuri_pool }
    default { pool my-default-pool }
    }

} }

2 Replies

  • Yes, It is possible. Change your iRule like this way:

    when HTTP_REQUEST {
        switch -glob [HTTP::uri] {
        "/myuri/abc*"  { 
    if { [active_members myuri_pool] > 0 } {
    pool myuri_pool 
    } else {
    pool my-default-pool
    }
    }
        default { pool my-default-pool }
        }
    }
    
  • May i ask which version are you using ? I tried this rule and sintax but i had some problem with the "switch -glob" command. I don't need "active_members" or "default-pool", it should be easier