nsmcp::ServerHistory method poolThreads (protected)

 <instance of nsmcp::ServerHistory[i]> poolThreads context options

Defined in /usr/local/ns/tcl/nsmcp/stats-tools.tcl

Parameters:
context (required)
options (required)

Testcases:
No testcase defined.
Source code:
set from [dict get $options from]
set to [dict get $options to]
set pool [dict get $options pool]
set first [expr {($from/60)*60}]
set end [expr {(($to+59)/60)*60}]
set slots [expr {($end-$first)/60}]
set busy [lrepeat $slots {}]
set maximum [lrepeat $slots {}]
set samples [lrepeat $slots 0]
set cursor 0
set pages 0
set total 0
while {1} {
    set h [${:command} history query -server [$context server] -from $from -to $to -limit 1000 -cursor $cursor]
    incr pages
    foreach record [dict get $h records] {
        incr total
        if {![dict exists $record sampling to] || ![dict exists $record servers [$context server] pools $pool gauges threads]} {
            continue
        }
        set at [dict get $record sampling to]
        if {![string is integer -strict $at]} {continue}
        set index [expr {($at-$first)/60}]
        if {$index<0 || $index>=$slots} {continue}
        set threads [dict get $record servers [$context server] pools $pool gauges threads]
        if {![dict exists $threads current] || ![dict exists $threads idle] || ![dict exists $threads max]} {continue}
        set current [dict get $threads current]
        set idle [dict get $threads idle]
        set max [dict get $threads max]
        if {![string is integer -strict $current] || ![string is integer -strict $idle]
            || ![string is integer -strict $max] || $current<0 || $idle<0 || $idle>$current || $max<0} {
            continue
        }
        set observed [expr {$current-$idle}]
        if {[lindex $busy $index] eq {} || $observed>[lindex $busy $index]} {
            lset busy $index $observed
        }
        lset maximum $index $max
        lset samples $index [expr {[lindex $samples $index]+1}]
    }
    if {![dict get $h more]} {break}
    set next [dict get $h nextCursor]
    if {![string is entier -strict $next] || $next<=$cursor || $pages>=12} {
        error "Pool thread history exceeded the bounded page budget"
    }
    set cursor $next
}
set fields [list pool string $pool from number $first to number $end bucketSeconds number 60  busyMax array [:numericOrNullArray $busy] configuredMax array [:numericOrNullArray $maximum]  sampleCount array [:numericArray $samples] totalSamples number $total  coverage object [:encode coverage [dict get $h coverage]]  limitations string {busyMax is the highest sampled current-minus-idle thread count in each minute, not an exact minute peak. configuredMax is the last sampled pool limit in that minute. Missing samples are null, not zero. These concurrency counts use a different unit from slow requests per minute.}]
return $fields
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: