Forum Discussion

Chase_Hoffman_2's avatar
Chase_Hoffman_2
Icon for Nimbostratus rankNimbostratus
Apr 12, 2013

iRule to parse status page and failover to secondary server/priority group

So I have a webserver, SERVERA. It's the primary node. There's a backup server, SERVERB, that should only be used if SERVERA is unavailable.

 

Due to some weirdness with the web application, the app sometimes goes unresponsive while port 80 is still responsive, as is the server. The application has an internal status page, statuspage.html, that returns a GOOD or BAD value depending on some internal checks.

 

I'm wondering, therefore, if it's possible for the F5 to parse http://SERVERA/site1/statuspage.html, https://SERVERA/site2/statuspage.html, etc., and if, say, all the sites returned BAD, failover to the secondary server. Is it possible to do this in an iRule?

 

Thank you in advance.

 

4 Replies

  • I think you don't even need an iRule for this one. Using priority group load balancing you can set different priority values for members of a pool, such that lower priority members will ONLY be used if the higher priority members become unavailable. Add all of the servers to the same pool and then assign priority numbers to the members (higher numbers = higher priority). Then enable priority group activation and set a threshold.

     

     

    Next you'll need an external monitor applied to the pool. The external monitor will need to point to a script (Perl, Bash, whatever) that can call (ex. via cURL) the status pages, parse the returned content, and return an up or down status to the applied monitor. There's some sample monitor scripts in /config/monitors to get you started. The monitor applied to the pool will periodically call the external script for each member of the pool. If the monitor indicates that ALL (or some defined threshold) of the higher priority members are down, only then will the pool use the lower priority members.

     

     

    If you provide more detail and samples of the status pages we may be able to assist with the monitor scripts. ;)
  • Kevin,

     

     

    Thanks for the prompt and helpful reply. The page literally just returns "OK" if working, or no text at all if not. I'll take a look in /config/monitors - I guess my biggest question at this point is how to define the threshold... I'm kinda a neophyte at this, so any direction you could give me would be really helpful.
  • Under the members tab of a defined pool, click on the help section to get more detail. Essentially though, once you enable priority group activation from the drop down box, "type a number from 0 to 65535 that represents the minimum number of members that must be available in one priority group before the system directs traffic to members in a lower priority group". So if you want the lower priority members to be used only if all of the higher priority members are down, enter a 1 in the threshold field.
  • Jnon's avatar
    Jnon
    Icon for Nimbostratus rankNimbostratus
    when you create a new monitor i.e. you could just look for OK in the receive string, then the default setting is every 5 seconds it performs a check, then after 3 fails on the 16th second it will mark it down. as Chase and Kevin mentioned you need to use priority activation, set one node to a higher priority and adjust the monitor intervals to your needs.