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

Filter by:
  • Solution
  • Technology
Answers

Pool Member Status Page on a Virtual Server v11

A few years ago someone posted this article:

https://devcentral.f5.com/wiki/irules.Pool__Member__Status__Page_on_a__Virtual__Server_v10.ashx

However, there's never been any updates for v11. I've seen numerous articles with bits and pieces in them but no full fix so I've decided to help fix that. From the original article I've only changed the first iRule not Joel's, even though it's the better of the two, and have removed the RSS section in order to keep this readable. You can make the same changes to Joel's script fairly easily.

For the iRule the only change was to make sure that the pools are sorted nicely when displaying them so I've changed this:

foreach { selectedpool } [class get pool_member_status_list] {

to this:

set pool_list [class get pool_member_status_list]

foreach  selectedpool [lsort -dictionary $pool_list] {

So that way we sort the list before displaying it.

Here's the iRule:

    when HTTP_REQUEST {

            set pool_list [class get pool_member_status_list]

        if { [HTTP::uri] eq "/status" } {
        set response "BIGIP Pool Member Statusasdf - \
        [clock format [clock seconds]]

BIGIP Pool Member Status - [clock format [clock seconds]]

\ " foreach selectedpool [lsort -dictionary $pool_list] { if { [catch { scan $selectedpool {%[^/]/%[^:]:%s} poolname addr port switch -glob [LB::status pool $poolname member $addr $port] { "up" { append response "\ " } "down" { append response "\ " } "session_enabled" { append response "\ " } "session_disabled" { append response "\ " } Default { log local0. [LB::status pool $poolname member $addr $port] append response "\ " } } #SWITCH END } errmsg] } { append response "\ " } } append response "
StatusPool NameMemberPort
UP[string tolower $poolname]$addr$port
DOWN[string tolower $poolname]$addr$port
ENABLED[string tolower $poolname]$addr$port
DISABLED[string tolower $poolname]$addr$port
INVALID[string tolower $poolname]$addr$port
INVALID[string tolower $poolname]$addr$port
" HTTP::respond 200 content $response "Content-Type" "text/html" "Cache-Control" "no-cache, must-revalidate" "Expires" "Mon, 26 Jul 1997 05

wow.. formatting didn't do me any favors there. anyhow. The iRule is pretty much the same as the one for v10 the main change is the bash script.

Now to the major changes, the bash script. The origional one used bigpipe which is gone in v11 so we need to migrate that to tmsh commands. But while we're doing that there is one shortcoming from the origional script we can get rid of; the need to completely reload the config after changing the data-group.

Here we're going to create a temp file and dump the pool data to there. Then, on the active box, we'll use tmsh to update the data-group. No reload necessary.

bash script:

#!/bin/bash

tmsh modify sys db bigpipe.displayservicenames value false

#
# there shouldn't be a file here but lets make sure it's gone before starting
#

classfile="/tmp/classfile"


rm -f ${classfile} 

for POOLNAME in `tmsh list ltm pool | grep -i "ltm pool" |  sort | awk '{print $3}'`; do

        for POOLMEMBER in `tmsh list ltm pool ${POOLNAME} | grep : | sort | awk '{print $1}'`; do

                echo \"${POOLNAME}/${POOLMEMBER}\", >> ${classfile} # /var/class/pool_member_status_list.class
        done

done


#
# check to see if we're the active box
#
if [[ $(tmsh show sys failover) == *active* ]]; then
        tmsh modify /ltm data-group external pool_member_status_list source-path file:${classfile}  separator ":="
fi


#
# clean up after ourselves
#
rm ${classfile}


exit 0
0
placeholder+image

I'm trying to recreate this based on the original and updated post. It looks like the creation of an external data group has changed and I have not been able to figure out how to create it. Has anyone worked through this?

Thanks,

Dave

0
Comments on this Reply
Comment made 10-Mar-2017 by Jason Adams

Hi Dave,

This is the format to create an external data-group via tmsh.

1. Create the External File:

    tmsh create sys file data-group pool_member_status_list_dg source-path file:${classfile} type string separator ":="

2. Create the ltm data-group configuration object:

    tmsh create ltm data-group external pool_member_status_list_dg external-file-name pool_member_status_list_dgfile

Here is the updates bash script I came up with:

#!/bin/bash

tmsh modify sys db bigpipe.displayservicenames value false

#
# there shouldn't be a file here but lets make sure it's gone before starting
#

classfile="/var/class/pool_member_status_list.class"

rm -f ${classfile}

for POOLNAME in `tmsh list ltm pool | grep -i "ltm pool" |  sort | awk '{print $3}'`; do
        for POOLMEMBER in `tmsh list ltm pool ${POOLNAME} | grep : | sort | awk '{print $1}'`; do
                echo "\"${POOLNAME}\" := \"${POOLMEMBER}\"," >> ${classfile}
        done
done

sed '$ s/.$//' -i ${classfile}

#
# check to see if we're the active box
#
if [[ $(tmsh show sys failover) == *active* ]]; then

        # Modify the data-group external file if it does exist, create it if it does not.
        tmsh list sys file data-group pool_member_status_list_dgfile > /dev/null 2>&1

        case $? in
        0)
                tmsh modify sys file data-group pool_member_status_list_dgfile source-path file:${classfile} separator ":="
                ;;
        *)
                tmsh create sys file data-group pool_member_status_list_dgfile source-path file:${classfile} type string separator ":="
                ;;
        esac

        # Create the ltm data-group if it does not already exist.
        tmsh list ltm data-group external pool_member_status_list_dg > /dev/null 2>&1

        case $? in
        0)
                ;;
        *)
                tmsh create ltm data-group external pool_member_status_list_dg external-file-name pool_member_status_list_dgfile
                ;;
        esac
fi

#
# clean up after ourselves
#
rm ${classfile}

exit 0

Cheers! -- Jason Adams --

0