Forum Discussion

Michael_-_Harr1's avatar
Michael_-_Harr1
Icon for Nimbostratus rankNimbostratus
Jan 10, 2017

Help with IRULE to send status 500 if all members of pool equal 0 and code 200 if at least 1 member is operational

Need help with IRULE please,

 

URL from client application https://online.mydomain.org/statusCheck2 to send a status code 500 if there are 0 pool members and if there at least 1 pool member send status code 200

 

In help creating this IRULE would be greatly appreciated.

 

2 Replies

  • This might work:

    when HTTP_REQUEST {
        if { [string tolower [HTTP::uri]] eq "/statuscheck2" && [active_members ] > 0 }{
            HTTP::respond 200 content ""
        } else {
            HTTP::respond 500 content ""
        }
    }
    

    Replace

    pool_name
    and
    your content
    with the correct values.

    /Patrik

  • This is an untested, rough iRule that you have to alter to suit your needs:

    when HTTP_REQUEST {
    if { [active_members WEB_POOL] < 1 } {
    HTTP::respond 500 Location "https://online.mydomain.org/statusCheck2"
    } elseif { [active_members WEB_POOL] > 0 } {
    HTTP::respond 200 Location "https://online.mydomain.org/statusCheck2"
    }
    }
    

    You can probably use switch instead of if-else.