Forum Discussion

Kdedesko_49781's avatar
Kdedesko_49781
Icon for Nimbostratus rankNimbostratus
Mar 04, 2015

Can anyone see anything wrong with these I-Rules?

Hi I am new to writing I-Rules and have put an I-Rule together that is quite simple and I think will work but am wondering if there is something obviously wrong with them before I implement them.

 

For a number of reasons I won't get into here, we are using an internet based global load balancing service that sends a basic get request to a VIP on an LTM. Basically if the servers in the LTM pool are up, the LTM responds with a 200. If the servers are down, it responds with a 404 or some error message, and the global LB will direct incoming requests to the backup data center.

 

Here is what I have put together. Is there something obviously wrong or may have missed?

 

rule TEST { when HTTP_REQUEST { if { [active_members [ LB::Test_Pool]] > 0 } { HTTP::respond 200

 

} else { HTTP::respond 404 } } }

 

where the Global Load Balancing service issues an HTTP request..

 

Thanks in advance.

 

Ken

 

3 Replies

  • Did you get a chance to check out the active_members wiki page, the LB::server pool command and the iRules 101 page on pools and members and such? They have some more specific details on this.

    I think your iRule may need a little tweak to get the pool name when checking for active members. You can either use

    [active_members POOL_NAME]
    to specify a pool name. Otherwise you could use
    [active_members [LB::server pool]]
    instead to get whatever the currently set pool is. (And I'd include the "Connection Close" header on the return as well)

    rule TEST { 
        when HTTP_REQUEST { 
            if { [active_members POOL_NAME] > 0 } { 
                HTTP::respond 200 content "" Connection Close
            } else { 
                HTTP::respond 404 content "" Connection Close
            } 
        } 
    }