Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
code share

Pool Member Status HTML5 Page

Problem this snippet solves:

This allows a publicly accessible status page of Pools and Pool Members. No cron job is needed.

How to install:

  1. Create iRule Data Group List called "BIG-IP_Pool_Member_Status" and include the Pools you want to show a status on*

  2. Create iRule using the code below.

  3. Create Virtual Server with Client SSL profile (most likely requires one with no pools so that it doesn't pass traffic on to pool members, thus "bypassing" the script)

  4. Test by accessing the VIP at: https://x.x.x.x/status

  • If you only have one pool, you will probably have to comment out the "errmsg" HTML response code. For some reason one pool in the Data Group List kicks out an error. "Errmsg" is on lines 60 and 121.

Edits to the code:

Line 3 - Modify to your IP scheme to lock down access, or allow all

Line 8 - Document title information (shows in browser tab)

Line 10 - Author information

Line 11 - Auto refresh interval (update line 30 if you change this)

Line 34 - Page title information

Lines 44-45 - Links to other locations if you have devices in different locations/groups

Line 122 - Comment out with a "#" if you don't wish to log each time someone connects or the page refreshes

*HTML source and inspiration taken from user The Bhattman and the code is revamped: https://devcentral.f5.com/codeshare/pool-member-status-page-on-a-virtual-server-v10

How to use this snippet:

Screenshot Image Text

Tested on Version:
12.1
Comments on this Snippet
Comment made 06-Apr-2017 by Maneesh 292

This is very good to get the details as we have number of developers who keep on chasing us for the pool member status.

0
Comment made 11-Apr-2017 by AN 165

I tried above code... I am getting ERROR: Invalid pool name

I put IP:PortNumber in BIG-IP_Pool_Member_Status Address: 1.1.1.1 Value: :80

Do we suppose to put pool name i under IRUle:Data Group List? We are using Partition on BigIP.

0
Comment made 11-Apr-2017 by LoyalSoldier 106

Yes, your pool names. The "IP:Port" in the image is what the result will look like when the page is processed.

So, under iRules | Data Group List you should have a list named "BIG-IP_Pool_Member_Status", with the string list of Pools you want. Nothing for the Value field.

Screenshot example: https://f5.com/Portals/1/Images/whitepaper-images/Enhancing%20Exchange%20Mobile%20Device%20Security/fig-7.jpg

0
Comment made 11-Apr-2017 by AN 165

That works,,, It wasn't clear Data Group list -> String we supposed to select. I had Address selected but once I changed to String and include pool member string,,, it started working,,,

Thanks again,,

0
Comment made 11-Apr-2017 by LoyalSoldier 106

Your welcome. Sorry about forgetting that piece of information.

0
Comment made 12-Apr-2017 by AN 165

No Problem.. It's an awesome Tool that allow application/server team to look for Pool status.

Thanks for sharing.

0
Comment made 12-Apr-2017 by Maneesh 292

LoyalSoldier is there a way we can get the output like an XML ?

I got 150+ Pools out of which around 60 are marked down/decommed but still lying in the config, as a result it takes top half of the page, if I have XML I can get the XML/JSON called from an external application and there I can put a search box in which user can input his search string to extract the required info.

Or for that matter if we can have something on this page itself that is also great.

0
Comment made 13-Apr-2017 by LoyalSoldier 106

Maneesh,

As far as an XML output, you would have to re-code the HTML into an XML style format. For an example, see this link, go to the bottom of the last block of code and look for the section starting with this: if { [HTTP::uri] eq "/rss" } {. It is RSS, which is XML, but you're more likely looking for XHTML, which is similar. https://devcentral.f5.com/codeshare/pool-member-status-page-on-a-virtual-server-v10/tag/irules

A built-in search feature sounds cool, but would have to be with a client side scripting ability, such as JavaScript. If you have a working example I can try and add it when I get time.

0
Comment made 14-Apr-2017 by Maneesh 292

when HTTP_REQUEST { # IP Block. Allow specific users/groups to access the status page. if { [IP::addr [IP::client_addr] equals 10.0.0.0/8 ] } { if { [HTTP::uri] eq "/servicexml" } { set response "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"

    # Code to display inactive pools in XML Format
    append response "<PoolNameDetails>\r\n"
    append response "<PoolNameStatus>Inactive<PoolNameStatus>\r\n"
                            foreach { selectedpool } [class get test] {
                            set thispool [getfield $selectedpool " " 1]
                                if {  [catch {
                                    if { [active_members $thispool] < 1 } {
                                        # Pool Status for pools with no active members
                                        append response "<PoolName>$thispool</PoolName>\r\n"
                                        } else {
                                        # Skip
                                    }
                                 } errmsg ] } {
                                    append response "<PoolNameError>$thispool: ERROR: Invalid pool name</PoolNameError>\r\n"
                                }
                            }


    # End XML containing "F5 Locations" and "Critical" sections.
    # Code to display active pools in XML Format

    append response "<PoolNameStatus>Active<PoolNameStatus>\r\n"
    foreach { selectedpool } [class get test] {
        set thispool [getfield $selectedpool " " 1]
        if {  [catch {
            if { [active_members $thispool] < 1 } {
                # Pool Status for pools with no active members
                # Skip.  This is implemented above in the first table.
                } else {
                # Pool Status
                    append response "<PoolName>$thispool</PoolName>\r\n"
                    # Pool Member Status Section
                    foreach { pmem } [members -list $thispool] {
                        append response "<PoolMember>$pmem</PoolMember>\r\n"
                                            set nodestatus "[LB::status pool $thispool member [getfield $pmem " " 1] [getfield $pmem " " 2]]"
                                            if {$nodestatus == "up"} {
                                                append response "<PoolMemberStatus>Up</PoolMemberStatus>\r\n"
                                            } elseif {$nodestatus == "down"} {
                                                append response "<PoolMemberStatus>Down</PoolMemberStatus>\r\n"
                                            } elseif {$nodestatus == "session_disabled"} {
                                                append response "<PoolMemberStatus>Disabled</PoolMemberStatus>\r\n"
                                            } else {
                                                append response "<PoolMemberStatus>$nodestatus</PoolMemberStatus>\r\n"
                                            }
                                            set nodestatus null
                    }
                }
            } errmsg ] } {
                append response "<PoolNameError>$thispool: ERROR: Invalid pool name</PoolNameError>\r\n"
            }

    }
    append response "</PoolNameDetails>\r\n"
    # End Pool Member Status Section

    HTTP::respond 200 content $response "Content-Type" "text"   
}

} }

0
Comment made 14-Apr-2017 by Maneesh 292

Thanks LoyalSoldier was able to convert the code to XML as mentioned above. Now can read the XML via an external HTML/JavaScript.

0
Comment made 14-Apr-2017 by LoyalSoldier 106

Cool. Can you upload the whole code for an XML solution?

0
Comment made 15-Apr-2017 by Maneesh 292

Above my comment I had already posted it.

0
Comment made 19-Apr-2017 by AN 165

Hi Maneesh,, Does you code allow users to select/search particular pool??

0
Comment made 19-Apr-2017 by Maneesh 292

For searching we would have to write a HTML page which calls XML using javascript for search capability.

I am asking a developer to assist me writing a HTML page for the same which will give search capability for finding pools. XML was taking long to load hence have coded a JSON i-rule which would be faster fetching results.

I would post the JSON code as well below this comment.

0
Comment made 19-Apr-2017 by Maneesh 292

when HTTP_REQUEST { # IP Block. Allow specific users/groups to access the status page. if { [IP::addr [IP::client_addr] equals 10.0.0.0/8 ] } { if { [HTTP::uri] eq "/json" } { set response "{ \"PoolDet\": ["

        foreach { selectedpool } [class get test] {
        set thispool [getfield $selectedpool " " 1]
        if {  [catch {
            if { [active_members $thispool] < 1 } {
                # Pool Status for pools with no active members
                            append response "{\"PoolName\": \"$thispool\","
                            append response "\"PoolStatus\":\"Inactive\"},"
                                                                            } else {
                # Pool Status
                                                                                            append response "{"
                                                                                            append response "\"PoolName\": \"$thispool\","
                                                                                            append response "\"PoolStatus\":\"Active\","
                                                                                            append response "\"PoolMemberDet\": \["
                                                                                            # Pool Member Status Section
                                                                                            foreach { pmem } [members -list $thispool] {                                
                                                                                                            append response "{\"PoolMember\": \"$pmem\","
                                                                                                                                                                                            set nodestatus "[LB::status pool $thispool member [getfield $pmem " " 1] [getfield $pmem " " 2]]"
                                                                                                                                                                                            if {$nodestatus == "up"} {
                                                                                                                                                                                                            append response "\"PoolMemberStatus\": \"Up\""
                                                                                                                                                                                            } elseif {$nodestatus == "down"} {
                                                                                                                                                                                                            append response "\"PoolMemberStatus\": \"Down\""
                                                                                                                                                                                            } elseif {$nodestatus == "session_disabled"} {
                                                                                                                                                                                                            append response "\"PoolMemberStatus\": \"Disabled\""
                                                                                                                                                                                            } else {
                                                                                                                                                                                                            append response "\"PoolMemberStatus\": \"$nodestatus\""
                                                                                                                                                                                            }
                                                                                                                                                                                            set nodestatus null
                                                                                                            append response "},"
                                                                                            }
                                                                                            append response "{ \"PoolMember\": \"filler\", \"PoolMemberStatus\": \"filler\" }\]},"
                                                                            }
                                                            } errmsg ] } {
                                                                            append response "\"PoolNameError\": \"$thispool: ERROR: Invalid pool name\""
                                                            }

                            }
                            append response "{"
                            append response "\"PoolName\": \"filler\","
                            append response "\"PoolStatus\":\"filler\""   
                            append response "}\]}"   
                            # End Pool Member Status Section

                            HTTP::respond 200 content $response "Content-Type" "application/json"      
            }

} }

0
Comment made 09-May-2017 by Jason 11

This is exactly what I have been looking for! But I am running into a little issue where pool members that are Offline still show as Up. The status of Disabled members show correctly. Any thoughts on what could be the issue?

Also, how hard would it be to add some additional information like hostname next to the IP:PORT and the description of the Pool next to the pool name?

Thanks in advance!

0
Comment made 09-May-2017 by LoyalSoldier 106

Jason,

Not sure why your Offline members are showing Up. I checked mine, and I have a couple members offline...one being due to a monitor setting it offline, and the other is due to manually disabling it. Both show Down on the HTML page. Maybe verify your settings/implementation is correct?

As far as adding the hostname... I looked into that while building the script and there was no easy/known way to incorporate the hostname from an iRule command, such as "[members -list $thispool]". The "members" command, for example, only pulls the IP and Port. Never tried looking at adding the description field.

With that said, you may be able to get those fields added using iCall, but I don't have enough experience with iCall, or time, to attempt it. If you or someone else wants to feel free. Can add that to the script if it works out.

One such example: https://devcentral.f5.com/questions/get-pool-member-names-in-irule-48260

0
Comment made 09-May-2017 by Jason 11

LoyalSoldier,

Yeah its very bizarre as I have a couple pools that are Offline (Enabled) due to monitoring, but the status page still shows those Up. I wouldnt think it mattered if the node showed as Up under Nodes but the monitor has it marked down at the pool, correct?

Even more bizarre, I have a pool that is disabled and I have seen it change to up randomly.

Im supposed to use that actually name of the pool the pool, correct? The only reason I ask is in your screen shot above the pool names look like just random characters.

0
Comment made 10-May-2017 by LoyalSoldier 106

So I did a test on one of mine and caused a Pool to go Offline (Enabled). All the Nodes are still Available (Enabled). Looking at the Status Page, it now shows that Pool as having no available pool members and lists it in the top Critical box. This is how it should be working. The code is executed based on the pool members, not nodes.

On your disabled pool that randomly changes to Up....does it do that in the Configuration Manager as well? Show the member(s) being marked up in the logs? Would make sure it is operating as expected first outside of the Status Page.

Yes, you must add the actual pool names to the iRule Data Groups area. The screenshot contains gray boxes in areas that will change based on your setup (i.e. Pool Name, IP:Port, etc.). You do NOT put your Pool Names in those areas. The code will do that for you based on the iRule Data Group.

0
Comment made 12-May-2017 by LenderLive_Mitch 110

Great little script! Thank you for sharing this.

0
Comment made 21-Jul-2017 by jaikumar_f5 1536

Works like a Charm !!! Thank you.

0
Comment made 02-Jan-2018 by AN 165

Hi Maneesh ,

I tried copying your code and it doesn't like... Tried to go through iRule..but can't get it going...

I changed following lines

Original: set response "{ \"PoolDet\": [" Changed to: set response "{ \"PoolDet\": }"

Now it's complaining about following line: if { [catch {

0
Comment made 04-Jan-2018 by LoyalSoldier 106

Hi AN,

It could be that you are missing a few closing "}". Looking at Maneesh's code, there are a couple "}" under the code input box.

0
Comment made 29-Jan-2018 by konta.eps 0

Hi, i am getting an error: http://prntscr.com/i7cy5a

Not sure what is misconfigured. I have followed instructions: -created VS -Created iRule -Created DataGroup

0
Comment made 29-Jan-2018 by LoyalSoldier 106

Hi konta.eps,

Did you create the Virtual Server with a Client SSL profile (most likely requires one with no pools so that it doesn't pass traffic on to pool members, thus "bypassing" the script)? If so, or whether you are using an existing one, is this VS load balancing with a pool? If so, try removing the pool from the VS, or test on a new one with no pool assigned (if you can't remove the pool due to being in production).

Other than that, does your VS's statistics show it being hit? Able to ping that IP? Other IPs on it working?

0
Comment made 07-Feb-2018 by konta.eps 0

I have created new client SSL profile and it works. Thank you, sir.

0
Comment made 22-Feb-2018 by DaleT 0

Works Perfectly.... This is everything i was looking for thanks.

0
Comment made 22-Mar-2018 by stevenSL 0

This is exactly what I was looking for. Thanks very much for posting.

0
Comment made 4 months ago by Siva balan 0

i am also getting similar like below error:

http://prntscr.com/i7cy5a

But i am using separate Client SSL profile and able to see the hits in VS's statistics.

is it applicable only for Common partition? or can i use this for different partition? Do i need make any changes for different partition?

0
Comment made 4 months ago by LoyalSoldier 106

Hi Siva,

When you say "separate Client SSL profile" are you actually referring to that, or a separate VIP that has no pool members? Seen it work best with a separate VIP with no pool members.

I built it on a system with only one partition: the common partition. I don't see why it couldn't work on another partition, but haven't tried that. It may require extra coding to specify the partition to use.

0
Comment made 4 months ago by ZinalA 0

Hey, Is there a way to report on every Pool status?

0
Comment made 4 months ago by LoyalSoldier 106

ZinalA,

It does report on every Pool status. Looking at the screenshot I included, you have "Pool Name" in the blue area, which is a placeholder for the actual pool names. Then under those you have the "Pool Member Status" for each of the members. If the whole Pool is down (no available members) then it will show in the Critical section.

If I'm not understanding then please explain.

0
Comment made 4 months ago by ZinalA 0

If LTM configuration is automated, this means that every pool has to be entered here as well. My question was if we can enable this view for every pool member hosted on the LTM.

0
Comment made 4 months ago by LoyalSoldier 106

LTM is not fully automated...you must configure per the instructions that are listed. Posted them below. Every pool member will automatically show up, but you must configure a Data Group List and add what Pools you want to monitor on that LTM. Each LTM would have its own similar configuration.

  • Create iRule Data Group List called "BIG-IP_Pool_Member_Status" and include the Pools you want to show a status on*
  • Create iRule using the code below.
  • Create Virtual Server with Client SSL profile (most likely requires one with no pools so that it doesn't pass traffic on to pool members, thus "bypassing" the script)
  • Test by accessing the VIP at: https://x.x.x.x/status
0
Comment made 4 months ago by Siva balan 0

I am using separate VIP that has no pool members and created new Client SSL profile.

Still facing the same issue. But the only different is, i am not using common partition.

0
Comment made 4 months ago by LoyalSoldier 106

Have you tested it for how it was meant to work - on the common partition? Just to rule that out.

0
Comment made 4 months ago by ZinalA 0

Create iRule Data Group List called "BIG-IP_Pool_Member_Status" and include the Pools you want to show a status on* If its a lB with Multiple VIPS which gets created on a daily basis, how can i include all pools. Do i need to add these manually or can i use some string that gets every pool?

Create iRule using the code below. I have created the irule.Do i need to attch this to the VIP as well?

Thanks for your help so far.

0
Comment made 4 months ago by ZinalA 0

Managed to get the hits on irules but i still dont see the page. I think this is because the Data Group List is incorrect. I am not too sure what string to use here i guess. LTM Version is 12.1.2 in case if the script is for older version.

0
Comment made 4 months ago by LoyalSoldier 106

So inside your Data Group List at location: Local Traffic ›› iRules : Data Group List ›› BIG-IP_Pool_Member_Status

You should have the list of your Pools you want to monitor. Should match exactly with what you have at Local Traffic ›› Pools : Pool List. You should be putting the pool names in the String field, and nothing in the Value field.

0
Comment made 4 months ago by ZinalA 0

thanks. Seems like the page wouldnt work even though i could see hits on VIP and iRule. I used the original code/irule that attached as Zip to this discussion. Hope thats correct.

0
Comment made 4 months ago by LoyalSoldier 106

Yes, original code in the zip is correct.

0