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

 <instance of ns::stats::Sampler[i]> sampling start \
    [ -interval interval ]

Defined in

Start the process-wide sampling callback at the requested interval in seconds (default 10, range 1..3600). Time units and fractional seconds are normalized with ns_baseunit. Repeated calls with the same running interval reuse the scheduler; a different interval requires stopping the sampler first. Clears the previous sample and baseline when starting a stopped sampler. Returns the resulting status dictionary. Persistence must be enabled separately.

Switches:
-interval (optional, defaults to "10")

Testcases:
No testcase defined.
Source code:
set interval [ns_baseunit -time $interval]
if {$interval < 1 || $interval > 3600} {
    error "interval must be 1..3600 seconds"
}
:locked {
    set state [nsv_get ns_stats control]
    if {[dict get $state running]} {
        if {[dict get $state interval]!=$interval} {
            error "sampler already running with a different interval; stop it before reconfiguring"
        }
    } else {
        dict incr state generation
        dict set state running true
        dict set state interval $interval
        dict set state busy false
        dict set state scheduler [ns_schedule_proc -thread $interval [self] sampling tick]
        nsv_set ns_stats pair {}
        nsv_set ns_stats control $state
    }
}
return [:sampling status]
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: