Forum Discussion
tmsh scripting poool member state
Guys,
Apologies in advance for the 'longish' pos (apologies if this is the wrong forum but it seemd appropriate)
The customer has two sites A and B, a gtm pool, with a member at each site. For reasons of their own the customer wants only site A
active, with a manual failover to B if required (no discussion here please, it's what the customeer wants, so that's what they're
getting).
To assist I thought I'd provide a 'simple' tmsh script (V11.2.1) which toggled the Active/Passive members - and then place in a bash
wrapper
e.g. Run the script, if Site A gtm pool member is enabled, disable it and Activate Site B gtm pool member, if Site B is Active when
run, disable it and enable Site A.
I've read the tmsh wikki (get_status, get_config, get_field_names etc), viewed and tried the LTM poool status example code, replaced
code such as:
foreach member [tmsh::get''field''value $obj members] (which balked the interpreter)
with
foreach member [tmsh::get_field_value $obj members]
and /ltm with /gtm
resulting in:
proc script::run {} {
set pool_names "sp.test.lan.pool"
foreach pn $pool_names {
set total 0
set usable 0
foreach obj [tmsh::get_status /gtm pool $pn detail] {
foreach member [tmsh::get_field_value $obj members] {
incr total
if { [tmsh::get_field_value $member pool-member.status.availability-state] == "available" &&
[tmsh::get_field_value $member pool-member.status.enabled-state] == "enabled" } {
incr usable
}
}
}
if { $usable > 0 && [expr 2 * $usable] >= $total } {
puts "up: $pn"
} else {
puts "dn: $pn"
}
}
}
but results in:
pool-status.tcl: script failed to complete:
can't eval proc: "script::run"
field not present: "pool-member.status.availability-state"
while executing
"tmsh::get_field_value $member pool-member.status.availability-state"
(procedure "script::run" line 11)
invoked from within
"script::run" line:1
script did not successfully complete, status:1
Given the time this has cost me so far just trying to get the status, I not even thinking about /modify script :(
Whilst I'm no Dennis Ritchie, I've used a few languages and script engines but this is killing me ... am I missing something?
Could anyone tell me if what I'm trying to do is viable or am I just wasting my time?
Any assistance would be greatly appreciated.
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
