nsmcp::AccessDiagnosticTool method trafficTriples (protected)
<instance of nsmcp::AccessDiagnosticTool> trafficTriples state \ duration complete
Defined in /usr/local/ns/tcl/nsmcp/traffic-tools.tcl
- Parameters:
- state (required)
- duration (required)
- complete (required)
- Testcases:
- No testcase defined.
Source code: set fields [list scope string examined-selected-records windowComplete boolean false scanComplete boolean $complete] foreach key {requestCount status503Count successfulCount successfulTimingCount successfulRunTotal unknownPeerCount untrackedSourceRecords unknownUserAgentCount untrackedUserAgentRecords} { lappend fields $key number [dict get $state $key] } set authentication {} if {[dict exists $state authenticationStates]} { dict for {name row} [dict get $state authenticationStates] { set entry {}; dict for {key value} $row {lappend entry $key number $value} lappend authentication $name object $entry } } lappend fields authenticationStates object $authentication set requests [dict get $state requestCount] lappend fields durationSeconds number $duration requestRate number [expr {$requests/double($duration)}] successfulTimingMissingCount number [expr {[dict get $state successfulCount]-[dict get $state successfulTimingCount]}] set peerReasons {} if {[dict get $state unknownPeerCount]} {lappend peerReasons 0 string missing-or-invalid-peer-fields} if {[dict get $state untrackedSourceRecords]} {lappend peerReasons 1 string source-cardinality-limit} set uaReasons {} if {[dict get $state unknownUserAgentCount]} {lappend uaReasons 0 string missing-user-agent-fields} if {[dict get $state untrackedUserAgentRecords]} {lappend uaReasons 1 string user-agent-cardinality-or-length-limit} set counts [lsort -integer -decreasing [dict values [dict get $state sources]]] set known [dict size [dict get $state sources]] lappend fields distinctKnownSources number $known observedPeerCountsComplete boolean [expr {$peerReasons eq ""}] peerCountsIncompleteReasons array $peerReasons observedUserAgentCountsComplete boolean [expr {$uaReasons eq ""}] userAgentCountsIncompleteReasons array $uaReasons sourceLimit number ${:maxAggregateSources} userAgentLimit number ${:maxAggregateUserAgents} if {$peerReasons eq ""} {lappend fields distinctSources number $known} else {lappend fields distinctSources null {}} set buckets {1 0 2-5 0 6-10 0 11-100 0 101-1000 0 1001+ 0} foreach count $counts { set bucket [expr {$count==1 ? "1" : ($count<=5 ? "2-5" : ($count<=10 ? "6-10" : ($count<=100 ? "11-100" : ($count<=1000 ? "101-1000" : "1001+"))))}] dict incr buckets $bucket } set histogram {}; dict for {key count} $buckets {lappend histogram $key number $count} lappend fields sourcesByRequestCount object $histogram set top {}; set rank 0; set sum 0 foreach count [lrange $counts 0 9] { incr sum $count lappend top $rank object [list rank number [expr {$rank+1}] requestCount number $count requestRate number [expr {$count/double($duration)}] share number [expr {$requests ? $count/double($requests) : 0.0}]] incr rank } lappend fields topSources array $top topTenSourceShare number [expr {$requests ? $sum/double($requests) : 0.0}] set rankings {} foreach {label metric} {byRequests requestCount by503 status503Count bySuccessfulRuntime successfulRunTotal} { set ordered {} dict for {ua row} [dict get $state agents] {lappend ordered [list [dict get $row $metric] $ua $row]} set output {}; set i 0 foreach item [lrange [lsort -real -decreasing -index 0 $ordered] 0 19] { lassign $item value ua row set entry [list userAgent string $ua] dict for {key count} $row {lappend entry $key number $count} lappend output $i object $entry incr i } lappend rankings $label array $output } lappend fields userAgents object $rankings distinctKnownUserAgents number [dict size [dict get $state agents]] rankingLimit number 20 omittedRankedUserAgents number [expr {max(0,[dict size [dict get $state agents]]-20)}] limitations string {Counts cover examined records selected by window, path and category, before evidence truncation. Rankings cover tracked redacted User-Agents, not verified bots. Source keys and addresses are never disclosed. Unknown fields and cardinality limits make observed distributions partial. Seek assumptions and rotations still limit time-window coverage; observed completeness is not window completeness. Rates use the requested window duration, not a rolling burst. Successful runtime is summed 2xx handler time, not CPU time.} return $fieldsXQL Not present: Generic, PostgreSQL, Oracle
![[i]](/resources/acs-subsite/ZoomIn16.gif)