ns::stats::Sampler method sampling status (public)

 <instance of ns::stats::Sampler[i]> sampling status

Defined in /usr/local/ns/lib/nsf2.5.0/lib/nx-traits.tcl

Return the process-wide sampler configuration and status, including running state, scheduler identifier, interval, process instance, collection errors and readiness of the latest interval sample. latestAt is in epoch seconds; ageSeconds is the elapsed time since the latest publication. Both are empty before the first sample. Does not collect new observations or modify sampler state.

Returns:
Status dictionary including running, interval in seconds, scheduler, instance, errors, lastError, ready, latestAt and ageSeconds.

Testcases:
No testcase defined.
Source code:
set result [nsv_get ns_stats control]
dict unset result busy
dict unset result generation
set sample [nsv_get ns_stats pair]
dict set result ready [expr {$sample ne "" && [dict get $sample sampling ready]}]
dict set result latestAt {}
dict set result ageSeconds {}
set limits [:memoryLimits]
dict set result retentionSeconds [dict get $limits retentionSeconds]
dict set result maxSamples [dict get $limits maxSamples]
dict set result maxWindowSeconds [expr {min([dict get $limits retentionSeconds],
                                             ([dict get $limits maxSamples]-1)*[dict get $result interval])}]
set recent [nsv_get ns_stats recent]
set available 0.0
if {$recent ne ""} {
    set last [lindex $recent end]
    set first $last
    foreach record [lreverse [lrange $recent 0 end-1]] {
        if {[dict get $first instance] ne [dict get $record instance]
            || [dict get $first instance] ne [dict get $result instance]
            || ![dict get $first sampling ready]
            || [dict get $first timestamp]-[dict get $record timestamp]
               > 1.5*max([dict get $first sampling intervalSeconds],
                         [dict get $record sampling intervalSeconds])*1000000} {break}
        set first $record
    }
    set available [expr {min([dict get $result maxWindowSeconds],
                            ([dict get $last timestamp]-[dict get $first timestamp])/1000000.0)}]
}
dict set result availableWindowSeconds $available
if {$sample ne ""} {
    set stamp [dict get $sample timestamp]
    dict set result latestAt [expr {$stamp/1000000.0}]
    dict set result ageSeconds [expr {max(0,([clock microseconds]-$stamp)/1000000.0)}]
}
return $result
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: