nsmcp::SystemLogPeers object method add (public)

 nsmcp::SystemLogPeers[i] add statsVar message includeAddresses \
    [ timestamp ] [ offset ]

Defined in /usr/local/ns/tcl/nsmcp/log-summary.tcl

Count one selected physical record before grouping and sampling.

Parameters:
statsVar (required)
Caller-owned bounded peer accumulator.
message (required)
Original logical record before redaction.
includeAddresses (required)
Whether the caller requested authorized addresses.
timestamp (optional)
Parsed warning time for optional context sampling.
offset (optional, defaults to "0")
Original warning byte offset.

Testcases:
No testcase defined.
Source code:
upvar 1 $statsVar stats
dict incr stats recordCount
set peer {}
if {[regexp {from peer ([^ \t\r\n]+)} $message -> value]} {
    if {![ns_ip valid $value]} {set value [string trimright $value :]}
    if {[ns_ip valid $value]} {set peer $value}
}
if {$peer eq {}} {dict incr stats unknownPeerRecords; return}
set key [expr {$includeAddresses ? $peer : [ns_crypto::md string -digest sha256 -- $peer]}]
if {![dict exists $stats counts $key] && [dict size [dict get $stats counts]]>=65536} {
    dict incr stats capacityOmittedRecords
    return
}
dict incr stats knownPeerRecords
set count 0
if {[dict exists $stats counts $key]} {set count [dict get $stats counts $key]}
dict set stats counts $key [expr {$count+1}]
if {$includeAddresses && $timestamp ne {}} {
    set kind other
    if {[string match {*received TLS handshake on a non-TLS connection*} $message]} {
        set kind tls-on-http
    } elseif {[string match {*received HTTP/2 connection preface on an HTTP/1 connection*} $message]} {
        set kind http2-preface
    }
    set sample [dict create timestamp $timestamp offset $offset  peerKey [ns_crypto::md string -digest sha256 -- $peer] kind $kind]
    set retained {}
    if {[dict exists $stats samples $peer]} {set retained [dict get $stats samples $peer]}
    if {![llength $retained]} {
        set retained [list $sample]
    } elseif {[llength $retained]==1} {
        lappend retained $sample
    } else {
        lset retained 1 $sample
    }
    dict set stats samples $peer $retained
}
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: