Forum Discussion
TJ_Vreugdenhil
Cirrus
Nov 05, 201311.x TMSH script to remove monitors on GTM VIP's
Hi -
We have over 800 GTM VIP Server Objects listed and we need to remove all the monitors associated with them so iQuery can work correctly.
I had a crack at creating a tmsh script and I feel very close... but can't quite get it.
This tmsh command is essentially want I would like to do, but apply it to all virtual servers, not just one:
modify /gtm server KC-LTM virtual-servers modify { VIPwith2monitors } monitor none
script delGTMVIPmonitors.tcl {
proc script::run {} {
tmsh::log_dest screen
tmsh::log_level alert
if { $tmsh::argc != 2 } {
puts "A single monitor name must be provided"
exit
}
set monitorname [lindex $tmsh::argv 1]
set monitors ""
set vips [tmsh::get_config /gtm server KC-LTM virtual-servers]
set vips_in_play ""
tmsh::begin_transaction
foreach VIP $vips {
If only 1 monitor name applied, can use the none attribute, otherwise, must
"pop" $monitorname from the monitorname list and re-apply
if { [llength $monitors] < 2 } {
tmsh::modify /gtm server KC-LTM virtual-servers modify { tmsh::get_name $VIP } monitor none
tmsh::log alert "after tmsh::modify the vips in play are $vips_in_play"
lappend vips_in_play $VIP
} else {
set id [lsearch -exact $monitors $monitorname]
set keepers [lreplace $monitors $id $id]
tmsh::modify /gtm server KC-LTM virtual-servers modify { tmsh::get_name $VIP } monitor "{ $keepers }"
lappend vips_in_play $VIP
}
}
tmsh::commit_transaction
tmsh::log alert "tmsh::commit the vips in play are $vips_in_play"
puts "The $monitorname was removed from the following vips: "
foreach x $vips_in_play {
puts "\t[tmsh::get_name $x]"
}
}
}
1 Reply
- Kevin_Stewart
Employee
I may have found an easier solution with a Bash script:
! /bin/bash (IFS=' ' Get GTM server names output=`tmsh list / gtm server |grep "gtm server" | awk -F" " '{ print $3 }'` Loop through GTM server names and remove monitors for f in ${output} do tmsh modify / gtm server $f virtual-servers modify { all { monitor none } } done)
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
