Watch LTM Pools
Problem this snippet solves:
Here's a way to monitor your current pools using a custom tmsh script.
Code :
cli script watch_pools.tcl { proc get_stats { resultsArray } { upvar $resultsArray results set idx 0 set objs [tmsh::get''status ltm pool $::pool''ids raw] set count [llength $objs] while { $idx < $count } { set obj [lindex $objs $idx] set pool [tmsh::get_name $obj] lappend results($pool) bps-in lappend results($pool) \ [tmsh::get''field''value $obj "serverside.bits-in"] lappend results($pool) bps-out lappend results($pool) \ [tmsh::get''field''value $obj "serverside.bits-out"] lappend results($pool) cps lappend results($pool) \ [tmsh::get''field''value $obj "serverside.tot-conns"] incr idx } } proc script::run { } { for {set idx 1} {$idx < $tmsh::argc} {incr idx} { lappend ::pool_ids [lindex $tmsh::argv $idx] } array set r1 {} array set r2 { } set interval 2 set delay [expr $interval * 1000] get_stats r1 while { true } { after $delay get_stats r2 tmsh::clear_screen foreach { pool } [lsort [array names r1]] { if { [string length [array names r2 -exact $pool]] == 0 } { puts "$pool: no sample" continue } set line [format "%-20s" $pool] set s1 $r1($pool) set s2 $r2($pool) set idx 0 set count [llength $s1] while { $idx < $count } { append line "[lindex $s1 $idx] " incr idx set stat \ [expr ([lindex $s2 $idx] - [lindex $s1 $idx]) / $interval] append line "[format "%-12s" $stat]" incr idx } puts $line } # use the most recent results as the next previous results array set r1 [array get r2] array unset r2 } } proc script::init { } { set ::pool_ids "" } proc script::help { } { tmsh::add_help "enter zero or more pool names" } proc script::tabc { } { foreach {pool} [tmsh::get_config /ltm pool] { tmsh::add''tabc [tmsh::get''name $pool] } } }
Published Mar 10, 2015
Version 1.0CodeCentral_194
Cirrus
Joined May 05, 2019
CodeCentral_194
Cirrus
Joined May 05, 2019
- Distance_VectorNimbostratus
Does not compile.
First, all '' must be _.
And then there's:
/Common/pool-stats:43: warning: [use curly braces to avoid double substitution][$interval] /Common/pool-stats:71: warning: [use curly braces to avoid double substitution][([lindex $s2 $idx]]
01070712:3: /Common/pool-stats:54: error: [wrong args][string length [array names r2 -exact $pool]]