nsmcp::AccessDiagnosticTool method signals (public)

 <instance of nsmcp::AccessDiagnosticTool[i]> signals context \
    options

Defined in /usr/local/ns/tcl/nsmcp/traffic-tools.tcl

Parameters:
context (required)
options (required)

Testcases:
No testcase defined.
Source code:
set server [$context server]
set path [:source $server $options]
if {$path eq {} || ![file isfile $path] || ![file readable $path]} {
    return [list {} object [list server string $server available boolean false  reason string {Configured slow-request log is missing, disabled or unreadable.}]]
}
set thresholds [:signalThresholds $server [dict get $options module]]
set from [dict get $options from]
set to [dict get $options to]
set bucket [dict get $options bucketSeconds]
set first [expr {int(floor($from/double($bucket)))*$bucket}]
set end [expr {int(ceil($to/double($bucket)))*$bucket}]
set slots [expr {($end-$first)/$bucket}]
set rows [dict create queue [lrepeat $slots 0] filter [lrepeat $slots 0]  connection [lrepeat $slots 0] logged [lrepeat $slots 0]]
set bounds [:scanBounds $context $options]
set low [dict get $bounds from]
set high [dict get $bounds to]
set maxBytes 67108864
set truncated [expr {$high-$low>$maxBytes}]
if {$truncated} {set low [expr {$high-$maxBytes}]}
set parsed 0
set missingTiming 0
set malformed 0
set selected 0
set perPool {}
set channel [open $path rb]
try {
    seek $channel $low
    if {$low>0} {
        seek $channel [expr {$low-1}]
        set preceding [read $channel 1]
        seek $channel $low
        if {$preceding ne "\n"} {gets $channel}
    }
    while {[tell $channel]<$high && [gets $channel line]>=0} {
        if {[string length $line]>65536} {incr malformed; continue}
        set record [::nsmcp::accessRecordParser parse [encoding convertfrom utf-8 [string trimright $line \r]]]
        if {$record eq {}} {incr malformed; continue}
        incr parsed
        set at [dict get $record startTime]
        if {$at<$from || $at>=$to ||
            ([dict get $options pool] ne "all" && [dict get $record pool] ne [dict get $options pool])} {continue}
        incr selected
        set index [expr {int(floor(($at-$first)/double($bucket)))}]
        if {$index<0 || $index>=$slots} {continue}
        set pool [dict get $record pool]
        if {![dict exists $perPool $pool]} {
            if {[dict size $perPool]>=16} {continue}
            dict set perPool $pool [dict create queue [lrepeat $slots 0] filter [lrepeat $slots 0]  connection [lrepeat $slots 0] logged [lrepeat $slots 0]]
        }
        set counts [dict get $rows logged]
        lset counts $index [expr {[lindex $counts $index]+1}]
        dict set rows logged $counts
        set counts [dict get $perPool $pool logged]
        lset counts $index [expr {[lindex $counts $index]+1}]
        dict set perPool $pool logged $counts
        set flags [:signalFlags $record $thresholds]
        if {$flags eq {}} {incr missingTiming; continue}
        foreach label {queue filter connection} {
            if {![dict get $flags $label]} {continue}
            set counts [dict get $rows $label]
            lset counts $index [expr {[lindex $counts $index]+1}]
            dict set rows $label $counts
            set counts [dict get $perPool $pool $label]
            lset counts $index [expr {[lindex $counts $index]+1}]
            dict set perPool $pool $label $counts
        }
    }
} finally {close $channel}
set series {}
foreach label {queue filter connection logged} {
    lappend series $label array [:signalArray [dict get $rows $label]]
}
set poolSeries {}
dict for {pool counts} $perPool {
    set fields {}
    foreach label {queue filter connection logged} {
        lappend fields $label array [:signalArray [dict get $counts $label]]
    }
    lappend poolSeries $pool object $fields
}
set limits {}
foreach label {queue filter connection} {
    set value [dict get $thresholds $label]
    lappend limits $label [expr {$value eq {} ? "null" : "number"}] $value
}
return [list {} object [list server string $server available boolean true pool string [dict get $options pool]  from number $first to number $end bucketSeconds number $bucket  thresholdsSeconds object $limits series object $series pools object $poolSeries  selectedRecords number $selected parsedRecords number $parsed malformedRecords number $malformed  missingTimingRecords number $missingTiming  coverage object [list currentFileOnly boolean true scannedBytes number [expr {$high-$low}]  unreadBytes number [expr {$low-[dict get $bounds from]}] truncated boolean $truncated  seekStrategy string [dict get $bounds strategy]  completionOrderAssumed boolean [expr {[dict get $bounds strategy] eq "completion-window"}]]  limitations string {The three series count distinct nslog threshold conditions and can overlap. They are not counts of all requests over a combined duration. Only the current slow-request log is scanned; rotations, seek-order assumptions and any unread bytes limit coverage.}]]
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: