RiverFish
Jan 06, 2017Altostratus
Modify script to allow more than one variable (pool).
This iCall script works great, but you can only add one variable (one pool name). Therefore, I have to create a separate script for each pool I want to check, which is not desirable. I need help finding the best way to modify the script so that multiple pool names can be added. That way I can have just the one script that checks multiple pools.
admin@(f5-device-001)(cfg-sync Standalone)(/S1-green-P:Active)(/Common)(tmos) list sys icall script check-members-script
sys icall script check-members-script {
app-service none
definition {
set pn "/Common/pool-fooapp.example.com"
set total 0
set usable 0
foreach obj [tmsh::get_status /ltm pool $pn detail] {
puts $obj
foreach member [tmsh::get_field_value $obj members] {
puts $member
incr total
if { [tmsh::get_field_value $member status.availability-state] == "available" && \
[tmsh::get_field_value $member status.enabled-state] == "enabled" } {
incr usable
}
}
}
if { [expr $usable.0 / $total] < 0.7 } {
tmsh::log "Available pool member threshold reached for $pn"
}
}
description none
events none
}
admin@(f5-device-001)(cfg-sync Standalone)(/S1-green-P:Active)(/Common)(tmos)