The Objective
This article is for you if you are looking for a solution for any of these scenarios
- Export or List All the Pools across All the Partitions
- Export or List All the Pools and their VIP mapping across all the partitions available
- Export or List All the Unused Pool information for housekeeping
- To know how many VIPs are using a Particular Pool etc.
All these can be done with the CSV report being generated by the script we are going to provide in this post.
This is designed using F5's own tmsh commands and it is more of a Simple Wrapper Shell script which make use of tmsh beneath
The Script
This is a Shell script using the tmsh commands and must be executed in the F5 appliance backend terminal (SSH)
#!/bin/bash
#
#
BASEDIR=`dirname $0`
TEMPVIPFILE=$BASEDIR/temp_listofvips
CSVFILE=$BASEDIR/POOL-VIP-MAPPING.CSV
echo "POOLNAME,VIPNAME"|tee $CSVFILE
PARTITIONSLIST=`tmsh list auth partition|grep -i ^auth|awk '{print $3}'`
echo " " > $TEMPVIPFILE
# Parse thru Partion and Get the list of VIPS and Save it as file
for PARTITION in $PARTITIONSLIST
do
LISTOFVIPS_WITHPOOLNAME=`tmsh -q list ltm virtual "/$PARTITION/*" pool >> $TEMPVIPFILE`
done
for PARTITION in $PARTITIONSLIST
do
LISTOFPOOLS=`tmsh -q list ltm pool "/$PARTITION/*"|grep -i "^ltm pool"|awk '{print $3}'`
for POOL in $LISTOFPOOLS
do
VIPNAME=`grep -i $POOL -B1 $TEMPVIPFILE|grep -iv "^ "|awk '{print $3}'`
echo $POOL,$VIPNAME| tee -a $CSVFILE
done
sleep 5
done
How to use?
- Copy the script and save it with
.sh
extension - Make sure it has execution privileges or simply enter
chmod a+x <scriptname>
- Execute the script using the following command
$ ./Export-Pools-with-VIP-mapping.sh
I have named my script as Export-Pools-with-VIP-mapping.sh
make sure you use the name of your choice.
The Sample CSV report Generated
Caveats
- It creates two files in the
BASE_DIRECTORY
where your script resides. One is a temp file for operation usage another one is a Report and the file names aretemp_listofvips
andPOOL-VIP-MAPPING.CSV
respectively - The script is tested with BigIP 11.6 with multiple partition environment and it works perfectly. But when it comes to PROD I would like to request you to try once in UAT/TEST setup before executing.
- User Discretion is Advised.
Hope it helps
Let me know your feedback/questions in comments section
Rate this article [ratings]
Thanks,
Sarav AK
Follow me on Linkedin My Profile Follow DevopsJunction onFacebook orTwitter For more practical videos and tutorials. Subscribe to our channel
Signup for Exclusive "Subscriber-only" Content