- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables
Class ::nsmcp::ServerHistory
::nsmcp::ServerHistorycreate ... \
[ -adminExample (default "") ] \
[ -adminSummary (default "") ] \
[ -command (default "::ns_stats") ] \
[ -description (default "Query persisted ns_stats intervals for the authenticated server. For peak analysis use mode summary. Mode pool-threads returns sampled busy and maximum connection threads, per-sample busy/current percentages summarized by bucket mean and maximum, waiting requests, and connection-slot occupancy against historical maxconnections per pool by minute or coarser bucket, plus process-wide database-pool SQL/handle-wait and block-device I/O indicators. capacityReachedSamples counts retained observations at the pool's connection-slot limit; sockets held by a driver after that limit are outside the pool waiting gauge. driverBacklog.peakDetails gives each reported driver's contribution in the single sample with the largest process-wide waiting-socket total. Sampling can miss shorter peaks, and the separately read thread and waiting gauges are not atomic. Counts, durations, rates and sampled thread gauges have different units; missing intervals remain null. mode records (default) retains raw paging. Use lastMinutes, period previous-hour, or explicit from/to (Unix seconds; half-open interval, at most 24 hours). Return persistence status and coverage including gaps, restarts, evictions and write failures. Never assume complete coverage from record count. Does not enable sampling or persistence. Requires separately configured ns_stats SQLite history.") ] \
[ -inputSchema (default " { "type": "object", "properties": { "mode": {"type": "string", "enum": ["records", "summary", "pool-threads"], "default": "records"}, "pool": {"type": "string", "description": "Exact connection pool or all; required for pool-threads"}, "bucketSeconds": {"type": "integer", "enum": [60, 300, 900, 3600], "description": "pool-threads only; defaults to 900 for windows over six hours, 300 over three hours, otherwise 60"}, "lastMinutes": { "type": "integer", "minimum": 1, "maximum": 1440, "default": 10 }, "period": { "type": "string", "enum": [ "previous-hour" ] }, "from": { "type": "integer", "minimum": 0, "description": "Inclusive Unix epoch seconds" }, "to": { "type": "integer", "minimum": 1, "description": "Exclusive Unix epoch seconds" }, "limit": { "type": "integer", "minimum": 1, "maximum": 100, "default": 100 }, "cursor": { "type": "integer", "minimum": 0, "description": "Paging timestamp in microseconds; requires explicit from/to" } }, "additionalProperties": false } ") ] \
[ -name (default "server_history") ] \
[ -outputSchema (default "") ] \
[ -permission (default "diagnostics.runtime.read") ]
Defined in /usr/local/ns/tcl/nsmcp/stats-tools.tcl
Class Relations
::nx::Class create ::nsmcp::ServerHistory \ -superclass ::nsmcp::StatsToolMethods (to be applied on instances)
execute (scripted, public)
<instance of nsmcp::ServerHistory> execute context arguments
Read retained runtime-history observations. Validate the requested mode and bounds, and retain explicit history coverage and availability metadata.
- Parameters:
- context (required)
- Authenticated request context carrying the principal, grants and selected server.
- arguments (required)
- Rooted ns_json typed triples for the tool's JSON argument object.
- Returns:
- A rooted JSON tool-result object, including availability or job metadata as appropriate.
- 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] } if {[dict get $options mode] eq "summary"} { lassign [:compactHistory $context $options] summary nextFields lappend fields summary object $summary nextArguments [expr {$nextFields eq "" ? "null" : "object"}] $nextFields return [list {} object $fields] } if {[dict get $options mode] eq "pool-threads"} { lappend fields poolThreads object [:poolThreads $context $options] return [list {} object $fields] } dict unset options mode 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
Validate runtime-history bounds and inspection mode. Decode the rooted JSON argument object and enforce this tool's option, range and combination constraints.
- Parameters:
- arguments (required)
- Rooted ns_json typed triples for the tool's JSON argument object.
- Returns:
- An empty result on success; invalid input raises RPC error -32602.
- Testcases:
- No testcase defined.
if {[catch { :options $arguments } message]} { return -code error -errorcode {NSMCP RPC -32602} $message }
- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables
![[i]](/resources/acs-subsite/ZoomIn16.gif)