LTM Pool Status
Problem this snippet solves:
Here's a way to display the status of your pool members using a custom tmsh script.
Code :
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
foreach obj [tmsh::get_status /ltm 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"
}
}
}
}Published Mar 10, 2015
Version 1.0CodeCentral_194
Cirrostratus
Joined May 05, 2019
CodeCentral_194
Cirrostratus
Joined May 05, 2019
5 Comments
- Jagdeesh129_177
Nimbostratus
i get below error: /Common/pool-status.tcl:15: error: [undefined procedure: tmsh::get''field''value][tmsh::get''field''value $obj members] - Arnaud_Lemaire
Employee
replace '' with underscore - aav_225917
Nimbostratus
On BIGIP v.11.5.3, script registers this error: There were warnings: /Common/pool-status.tcl:20: warning: [use curly braces to avoid double substitution][$usable]. After adding curly braces and executing script, I get this error: run cli script pool-status.tcl enter one or more pool names script did not successfully complete, status:1 - Darius1_341345
Nimbostratus
I finally got this working.
In addition to replacing the '' with underscore (i.e.
becomesget''field''value
), delete "pool-member" on lines 15 and 16 and enclose in quotes.get_field_value(i.e.) Change
topool-member.status.availability-state
and"status.availability-state"
topool-member.status.enabled-state"status.enabled-state" - Jorgle
Nimbostratus
can not find the field name of "pool-member.status.availability-state"
# run cli script pool-status pool-100-208
pool-status: 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 14)
invoked from within
"script::run" line:1
script did not successfully complete, status:1