In 10.1 you can do something like the script below. You still need to look at a couple values, but you can be more specific about what you are looking for and are not dependent on command output formatting.
You could also up/down the dummy pool in this script based on status results.
bash tmsh
(tmos) create cli script pool-status.tcl
Then call the script from somewhere.
tmsh run cli script pool-status.tcl
create script pool-status.tcl {
proc script::run {} {
set pool_names ""
if { $tmsh::argc == 1 } {
puts "enter one or more pool names"
exit 1
}
set pool_names [lrange $tmsh::argv 1 end]
foreach pn $pool_names {
set total 0
set usable 0
get the status of each pool
foreach obj [tmsh::get_status /ltm pool $pn detail] {
if { [tmsh::get_type $obj] != "ltm pool-member" } {
continue
}
incr total
if { [tmsh::get_field_value $obj pool-member.status.availability-state] == "available" &&
[tmsh::get_field_value $obj pool-member.status.enabled-state] == "enabled" } {
incr usable
}
}
example, require a quorum to consist of at least half of the members
if { $usable > 0 && [expr 2 * $usable] >= $total } {
puts "up: $pn"
} else {
puts "dn: $pn"
}
}
}
}