# iRule to check if pool member is unavailable.

**URL:** <https://community.f5.com/t/irule-to-check-if-pool-member-is-unavailable/58366>\
**Category:** Technical Forums\
**Tags:** irules, devops, ltm\
**Created:** [March 10, 2020, 12:40pm UTC](https://community.f5.com/t/irule-to-check-if-pool-member-is-unavailable/58366 "2020-03-10T12:40:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![steve\_d1](https://avatars.discourse-cdn.com/v4/letter/s/2bfe46/32.png) [@steve\_d1](https://community.f5.com/u/steve_d1)\
**Post date:** [March 10, 2020, 12:40pm UTC](https://community.f5.com/t/irule-to-check-if-pool-member-is-unavailable/58366/1 "2020-03-10T12:40:21Z")

</div>

I would like to create an iRule that checks if all pool members. If these are unavailable or all down it should send a response that the page is currently unavailable.

Following irule works perfectly when the pool members are DOWN:

when HTTP\_REQUEST {

if { [active\_members [LB::server pool]] == 0 } {

HTTP::respond 503 content “Service Temporarily Unavailable”

}}

But the response is not send when pool members are marked as unavailable, for example by a https monitor where the disable string has been received.

Is there a way how you can check if pool members are unavailable?

---

<div class="post-metadata">

**Author:** ![iaine](https://avatars.discourse-cdn.com/v4/letter/i/f07891/32.png) [@iaine](https://community.f5.com/u/iaine)\
**Post date:** [March 11, 2020, 11:21am UTC](https://community.f5.com/t/irule-to-check-if-pool-member-is-unavailable/58366/2 "2020-03-11T11:21:33Z")

</div>

Hi

This is because of this - [myF5](https://support.f5.com/csp/article/K86025623)

Take a look at [https://devcentral.f5.com/s/articles/irules-recipe-4-static-maintenance-page-23131](https://devcentral.f5.com/s/articles/irules-recipe-4-static-maintenance-page-23131) and Vernons’ comments

---

<div class="post-metadata">

**Author:** ![gersbah](https://avatars.discourse-cdn.com/v4/letter/g/dc4da7/32.png) [@gersbah](https://community.f5.com/u/gersbah)\
**Post date:** [March 13, 2020, 4:51pm UTC](https://community.f5.com/t/irule-to-check-if-pool-member-is-unavailable/58366/3 "2020-03-13T16:51:36Z")

</div>

As far as I can tell, that article only applies when you have **manually** disabled pool members that would otherwise be online. (Pool member status shows a black circle and mouseover text “Available (Disabled) - Pool member is available, user disabled”)

This then also results in the virtual server status with a gray circle “Available (Disabled Parent) - The children pool member(s) might be disabled”

In any scenario where a health check automatically marks all pool members down, the pool members go into status offline, the vserver status also switches to offline and the above iRule works perfectly fine. At least for me, with version 14.

Which by the way also opens up a simple, if not very elegant, workaround: Instead of manually disabling the entire pool, just attach a monitor with an impossible condition to mark all members offline.

If there are any scenarios where what I wrote is not correct, I’d really like to know, because that could certainly come to bite me in my backside.

---

<div class="post-metadata">

**Author:** ![crodriguez](https://avatars.discourse-cdn.com/v4/letter/c/b77776/32.png) [@crodriguez](https://community.f5.com/u/crodriguez)\
**Post date:** [March 13, 2020, 6:19pm UTC](https://community.f5.com/t/irule-to-check-if-pool-member-is-unavailable/58366/4 "2020-03-13T18:19:27Z")

</div>

You can also reference [K6510: BIG-IP system fallback host behavior when a host is down](https://support.f5.com/csp/article/K6510) for information on using Fallback Host in the associated HTTP profile. It provides an alternative that does not include iRules, which is more efficient, but comes with some caveats. It also shows an iRule that triggers on LB\_FAILED rather than HTTP\_REQUEST, which is far more efficient since HTTP\_REQUEST is triggered for every request, while LB\_FAILED is only triggered if there is a problem with establishing the server-side connection, such as no available pool members. Here’s the iRule code from that article that redirects the request to an apology server. (Instead of **HTTP::fallback** , you could do your HTTP::respond 503.):

```tcl
when LB_FAILED {
     if { [active_members [LB::server pool]] < 1 } {
          # The redirect will be sent only if LB_FAILED
          # was because the pool had no available members.
          HTTP::fallback "http://example.com/redirect.html"
     }
}

```

---

<div class="post-metadata">

**Author:** ![steve\_d1](https://avatars.discourse-cdn.com/v4/letter/s/2bfe46/32.png) [@steve\_d1](https://community.f5.com/u/steve_d1)\
**Post date:** [March 18, 2020, 11:40am UTC](https://community.f5.com/t/irule-to-check-if-pool-member-is-unavailable/58366/5 "2020-03-18T11:40:36Z")

</div>

Thanks for all your input. we discovered we are hitting following bug:

> **[Bug ID 783617](https://cdn.f5.com/product/bugtracker/ID783617.html)**

Upgrade to 15.1..0 fixed the issue
