ns::stats::Sampler method sample (public)
<instance of ns::stats::Sampler> sample [ -server server ]
Return the latest published sample, updating its reported age and running state. Before any publication, return a dictionary with sampling readiness false and no interval observations. An optional server argument restricts virtual-server data; CPU measurements remain process-wide. Does not collect observations or advance the baseline. The internal raw baseline is omitted from the returned dictionary.
- Switches:
- -server (optional)
- Testcases:
- No testcase defined.
Source code: if {$server ne "" && $server ni [ns_info servers]} { error "unknown server: $server" } set result [nsv_get ns_stats pair] if {$result eq ""} { return [dict create schemaVersion 1 sampling {ready false from {} to {} elapsedSeconds {} ageSeconds {} reset false} servers {} availability {}] } dict set result sampling running [dict get [nsv_get ns_stats control] running] dict set result sampling ageSeconds [expr {max(0,([clock microseconds]-[dict get $result timestamp])/1000000.0)}] dict unset result raw # CPU is process-wide; filtering server pools never attributes CPU to a vhost. return [:selectServer $result $server]XQL Not present: Generic, PostgreSQL, Oracle
![[i]](/resources/acs-subsite/ZoomIn16.gif)