Forum Discussion
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)
- RiverFishAltostratus
This appears to be working well:
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 pool_names "/Common/pool-fooapp1.example.com /Common/pool-fooapp2.example.com /Common/pool-fooapp3.example.com" foreach pn $pool_names { 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)
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects