Forum Discussion
Pranav_73262
Nimbostratus
Aug 27, 2013How to disable Virtual Server in LTM using TMSH command?
Hi, we need to accomplish following task using shell script/tmsh in LTM v 11.3
For maintenance purpose, we need a script which will bring down all VSs related to particular client & can bring it up o...
Kevin_Stewart
Employee
Aug 28, 2013Here'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.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects