nsmcp::ServerHistory method options (protected)
<instance of nsmcp::ServerHistory> options arguments
Defined in /usr/local/ns/tcl/nsmcp/stats-tools.tcl
- Parameters:
- arguments (required)
- Testcases:
- No testcase defined.
Source code: if {[lindex $arguments 1] ne "object"} { error "Expected arguments object" } set options {limit 100 cursor 0 mode records} foreach {key type value} [lindex $arguments 2] { if {$key eq "mode"} { if {$type ne "string" || $value ni {records summary pool-threads}} { error "mode must be records, summary or pool-threads" } } elseif {$key eq "pool"} { if {$type ne "string" || $value eq "" || [string length $value] > 64} { error "pool must be a nonempty name of at most 64 characters" } } elseif {$key eq "period"} { if {$type ne "string" || $value ne "previous-hour"} { error "period must be previous-hour" } } elseif {$key ni {lastMinutes from to limit cursor bucketSeconds} || $type ne "number" || ![string is entier -strict $value]} { error "Supply integer time and paging options, or period previous-hour" } dict set options $key $value } set explicit [expr {[dict exists $options from] || [dict exists $options to]}] set relative [expr {[dict exists $options lastMinutes] + [dict exists $options period]}] if {$relative > 1 || ($explicit && $relative)} { error "Use lastMinutes, period, or paired from/to" } if {$explicit && (![dict exists $options from] || ![dict exists $options to])} { error "Supply both from and to" } if {!$explicit && [dict get $options cursor] != 0} { error "Paging requires the returned explicit from/to bounds" } set now [clock seconds] if {[dict exists $options period]} { set end [expr {($now / 3600) * 3600}] dict set options from [expr {$end - 3600}] dict set options to $end dict unset options period } elseif {!$explicit} { set minutes 10 if {[dict exists $options lastMinutes]} { set minutes [dict get $options lastMinutes] dict unset options lastMinutes } if {$minutes < 1 || $minutes > 1440} { error "lastMinutes must be 1..1440" } set end [expr {($now / 60) * 60}] dict set options from [expr {$end - $minutes * 60}] dict set options to $end } dict with options {} if {$from < 0 || $to <= $from || $to > $now || $to - $from > 86400 || $limit < 1 || $limit > 100 || $cursor < 0 || ($cursor != 0 && ($cursor < $from * 1000000 || $cursor >= $to * 1000000))} { error "Expected a past window up to 24 hours, limit 1..100 and a cursor within the window" } if {[dict get $options mode] eq "summary" && [dict get $options limit] != 100} { error "limit applies to records mode; summary uses fixed bounded pages of 100" } if {[dict get $options mode] eq "pool-threads"} { if {![dict exists $options pool] || $cursor != 0 || $limit != 100} { error "pool-threads requires pool; limit and cursor are unavailable" } if {[dict exists $options bucketSeconds] && [dict get $options bucketSeconds] ni {60 300 900 3600}} { error "bucketSeconds must be 60, 300, 900 or 3600" } if {![dict exists $options bucketSeconds]} { set span [expr {$to-$from}] dict set options bucketSeconds [expr {$span>21600 ? 900 : ($span>10800 ? 300 : 60)}] } } elseif {[dict exists $options pool]} { error "pool applies only to pool-threads mode" } elseif {[dict exists $options bucketSeconds]} { error "bucketSeconds applies only to pool-threads mode" } return $optionsXQL Not present: Generic, PostgreSQL, Oracle
![[i]](/resources/acs-subsite/ZoomIn16.gif)