Irule for failover between pools

I need to write an irule for failover. If pool1 is available then use Pool1 else use Pool2 else send a message saying that Application is not available.

you may try to check if pool is available using active_members and send http response (when no pool is available) using HTTP::respond. active_members   F5 Cloud Docs HTTP::respond   F5 Cloud Docs

I think priority groups would be a better way to address this, with an iRule just for a sorry response. So one pool, 3 different priority groups, 1 min per group.