Failover to standby device if health check fails

I want to set up a standby pool to be used only if the primary pool fails. Would an iRule be used to determine if the healthcheck fails on pool 1 then use pool2.

I have found a solution for this issue. Set up 2 pools one with the active devices one with the standby devices. If the healthchecks all fail then the following irule kicks in

when LB_FAILED {

LB::reselect pool Pool2

}