Forum Discussion
I have not tested this script with gtm changes but it should work. This scrip will list the ltm pools and member status. If you change the first in the script::run to
set objs [tmsh::get_status /gtm pool members] it should work.
modify script show-pools.tcl {
proc script::init { } {
set ::field_fmt "%-25s %s"
}
proc script::run { } {
set objs [tmsh::get_status /ltm pool members]
set idx 0
set total [llength $objs]
while { $idx < $total } {
set obj [lindex $objs $idx]
print_object obj
puts ""
incr idx;
}
}
proc print_fields { objVar } {
upvar $objVar obj
set fdx 0
set fields [tmsh::get_field_names value $obj]
set field_count [llength $fields]
while { $fdx < $field_count } {
set field [lindex $fields $fdx]
switch $field {
"pool.status.availability-state" -
"pool.status.enabled-state" -
"pool-member.status.availability-state" -
"members" { puts -nonewline "[tmsh::get_field_value $obj $field] " }
default {}
}
incr fdx
}
}
proc print_object { objVar } {
upvar $objVar obj
puts -nonewline "[tmsh::get_type $obj] [tmsh::get_name $obj] "
name/value pairs
print_fields obj
nested objects
set fdx 0
set fields [tmsh::get_field_names nested $obj]
set count [llength $fields]
while { $fdx < $count } {
set field [lindex $fields $fdx]
set nested_objects [tmsh::get_field_value $obj $field]
set ndx 0
set n_count [llength $nested_objects]
while { $ndx < $n_count } {
set nobj [lindex $nested_objects $ndx]
print_object nobj
incr ndx
}
if {$n_count == 0 } {
puts -nonewline [format $::field_fmt $field "none"]
}
incr fdx
}
}
}