Forum Discussion
How 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 on e maintenance window is over. Script should take client name as input & disble/enable all VS related to that client. Is it possible doing shell/perl script? Which commands I should use for tmsh, also will it support switch statement for looping or checking client name?
5 Replies
- nitass
Employee
Script should take client name as input & disble/enable all VS related to that client.
how does client name relate to virtual server (i.e. how do you know what virtual server is based on client name)?
- Pranav_73262
Nimbostratus
we will have to do manual mapping of client names with VS. e.g.: switch (Client A) { Disable VS1 Disable VS2 } switch (Client B) { Disable VS3 Disable VS4 } Is it possible to do?
- nitass_89166
Noctilucent
Script should take client name as input & disble/enable all VS related to that client.
how does client name relate to virtual server (i.e. how do you know what virtual server is based on client name)?
- Pranav_73262
Nimbostratus
we will have to do manual mapping of client names with VS. e.g.: switch (Client A) { Disable VS1 Disable VS2 } switch (Client B) { Disable VS3 Disable VS4 } Is it possible to do?
- Kevin_Stewart
Employee
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 fiI 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
* 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