Forum Discussion
Kevin_Stewart
Aug 28, 2013Employee
Here's an idea. Put the client name in the description block of the virtual server definition and use a shell script like this:
!/bin/bash
if [ -z "$1" ] || [ -z "$2" ]
then
echo "Usage: clientdown.sh [CLIENTNAME] [UP/DOWN]"
elif [ "$2" != "UP" ] && [ "$2" != "DOWN" ]
then
echo "Usage: clientdown.sh [CLIENTNAME] [UP/DOWN]"
else
output=$(tmsh list /ltm virtual one-line |grep "description $1" | awk -F" " '{ print $3 }')
if [ -z "${output}" ]
then
echo "No client found by that name"
else
for LINE in ${output}
do
if [ "$2" == "UP" ]
then
echo "Enabling virtual \"${LINE}\" for client $1"
tmsh modify /ltm virtual ${LINE} enabled
elif [ "$2" == "DOWN" ]
then
echo "Disabling virtual \"${LINE}\" for client $1"
tmsh modify /ltm virtual ${LINE} disabled
fi
done
fi
fi
I didn't bother making the command line arguments case-insensitive, so you'd need to have a naming/case convention for your client names (or modify the script). This will search through the VIP list for a given client name in the description field and then enable or disable those.