Watch GTM Pools
Problem this snippet solves:
Here's a way to monitor your current gtm pools preferred, alternate, and dropped counts using a custom tmsh script.
Code :
cli script watch_gtmPools.tcl { proc script::init {} { set ::pool_ids "" } proc get_stats { resultsArray } { upvar $resultsArray results set idx 0 set objs [tmsh::get''status gtm 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) preferred lappend results($pool) \ [tmsh::get''field''value $obj "preferred"] lappend results($pool) alternate lappend results($pool) \ [tmsh::get''field''value $obj "alternate"] lappend results($pool) dropped lappend results($pool) \ [tmsh::get''field''value $obj "dropped"] 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::help {} { tmsh::add_help "enter zero or more pool names" } proc script::tabc {} { foreach {pool} [tmsh::get_config /gtm 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
1 Comment
Sort By
- yingweizhao_137Nimbostratus
very good