Forum Discussion

Shoaib_020's avatar
Shoaib_020
Icon for Altostratus rankAltostratus
Nov 29, 2023

Need help in finding pools with only only one pool member

Hello, I need help in finding pools with only only one pool member. Please let me know if this can be done via any command or script.
  • PhatANhappy's avatar
    Nov 29, 2023

    I would start with:

    From cil - in bash...

    tmsh list ltm pool all members

    and start my filter with

     tmsh list ltm pool all members |egrep 'ltm pool|address' 

    if you dont need/use  ipv6

    tmsh list ltm pool all members |egrep 'ltm pool|address' |egrep -v 'any6'

    that should get you close

  • Michael_Saleem's avatar
    Nov 29, 2023

    You can achieve this using a simple bash script. For example:

    # Author: Michael Saleem
    # Filename: f5-list-pools-based-on-member-quantity.sh
    # Purpose:  This script will list all pools containing a specified number of pool members
    
    #!/bin/bash
    
    POOL_MEMBER_QUANTITY=1
    
    POOLS=$(tmsh list ltm pool one-line | awk '{print $3}')
    
    for POOL in $POOLS; do
    POOL_MEMBER_COUNT=$(tmsh list ltm pool $POOL one-line | awk -F':' '{print NF -1}';)
    
    if [ "$POOL_MEMBER_COUNT" = "$POOL_MEMBER_QUANTITY" ]
        then echo $POOL
    fi
    done