Class ::nsmcp::ServerHistory
::nsmcp::ServerHistory
create ... \
[ -command (default "::ns_stats") ] \
[ -description (default "Query persisted ns_stats intervals for the authenticated server. Defaults to the last 10 completed minutes. Use lastMinutes, period previous-hour, or explicit from/to (Unix seconds; half-open interval, at most 24 hours). Return records, referenced topologies, persistence status and coverage including gaps, restarts, evictions and write failures. Never assume complete coverage from record count. Follow nextArguments unchanged for stable paging; a page is not a complete window. Does not enable sampling or persistence. Requires separately configured ns_stats SQLite history. Process metrics remain process-wide.") ] \
[ -inputSchema (default "{} object {type string object properties object {
lastMinutes object {type string integer minimum number 1 maximum number 1440 default number 10}
period object {type string string enum array {0 string previous-hour}}
from object {type string integer minimum number 0 description string {Inclusive Unix epoch seconds}}
to object {type string integer minimum number 1 description string {Exclusive Unix epoch seconds}}
limit object {type string integer minimum number 1 maximum number 100 default number 12}
cursor object {type string integer minimum number 0 description string {Paging timestamp in microseconds; requires explicit from/to}}
} additionalProperties boolean false}") ] \
[ -name (default "server_history") ] \
[ -outputSchema (default "") ] \
[ -permission (default "diagnostics.runtime.read") ]
Defined in /usr/local/ns/tcl/nsmcp/lib/stats-tools.tclClass Relations
- class: ::nx::Class
![[i]](/resources/acs-subsite/ZoomIn16.gif)
- superclass: ::nsmcp::StatsTool
![[i]](/resources/acs-subsite/ZoomIn16.gif)
::nx::Class create ::nsmcp::ServerHistory \
-superclass ::nsmcp::StatsTool
Methods (to be applied on instances)
execute (scripted, public)
<instance of nsmcp::ServerHistory
> execute context arguments
- Parameters:
- context (required)
- arguments (required)
- Testcases:
-
No testcase defined.
if {![:available]} {
return [:unavailable $context]
}
set options [:options $arguments]
set status [${:command} history status]
set configured [dict exists $status pool]
set fields [list server string [$context server] available boolean true configured boolean $configured persistence object [:encode metrics $status]]
if {!$configured} {
lappend fields reason string {Configure ns_stats history with a dedicated nsdbsqlite pool to retain interval samples.}
return [list {} object $fields]
}
set query [list ${:command} history query -server [$context server]]
dict for {key value} $options {
lappend query -$key $value
}
set history [{*}$query]
lappend fields history object [:encode history $history]
if {[dict get $history more]} {
set next [list from number [dict get $history from] to number [dict get $history to] limit number [dict get $options limit] cursor number [dict get $history nextCursor]]
lappend fields nextArguments object $next
} else {
lappend fields nextArguments null {}
}
return [list {} object $fields]validate (scripted, public)
<instance of nsmcp::ServerHistory
> validate arguments
- Parameters:
- arguments (required)
- Testcases:
-
No testcase defined.
if {[catch {:options $arguments} message]} {
return -code error -errorcode {NSMCP RPC -32602} $message
}