Skip to content

Commit

Permalink
Extend client telemetry with per-host stats and limits (#174)
Browse files Browse the repository at this point in the history
Extends CLI telemetry objects to include packet capture statistics by host.
Also adds fields to track whether the CLI hit an upper limit imposed on the
number of hosts, ports, or interfaces it collects.
  • Loading branch information
thatplguy authored Nov 11, 2022
1 parent bb7c4fb commit 61b8b17
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions client_telemetry/pcap_stats.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package client_telemetry

// We produce a set of packet counters indexed by interface and
// We produce a set of packet counters indexed by interface, host and
// port number (*either* source or destination.)
type PacketCounts struct {
// Flow
Interface string `json:"interface"`
SrcHost string `json:"src_host"`
DstHost string `json:"dst_host"`
SrcPort int `json:"src_port"`
DstPort int `json:"dst_port"`

Expand Down Expand Up @@ -41,13 +43,25 @@ func (c *PacketCounts) Copy() *PacketCounts {
// Reflects the version of the JSON encoding. Increase the minor version
// number for backwards-compatible changes and the major number for non-
// backwards compatible changes.
const Version = "v0.2"
const Version = "v0.3"

type PacketCountSummary struct {
Version string `json:"version"`
Total PacketCounts `json:"total"`
TopByPort map[int]*PacketCounts `json:"top_by_port"`
TopByInterface map[string]*PacketCounts `json:"top_by_interface"`
TopByHost map[string]*PacketCounts `json:"top_by_host"`

// Maximum number of elements allowed in the TopByX maps.
ByPortOverflowLimit int `json:"by_port_overflow_limit"`
ByInterfaceOverflowLimit int `json:"by_interface_overflow_limit"`
ByHostOverflowLimit int `json:"by_host_overflow_limit"`

// Counts for elements in excess of the overflow limits. Nil means
// there was no overflow.
ByPortOverflow *PacketCounts `json:"by_port_overflow,omitempty"`
ByInterfaceOverflow *PacketCounts `json:"by_interface_overflow,omitempty"`
ByHostOverflow *PacketCounts `json:"by_host_overflow,omitempty"`
}

func NewPacketCountSummary() *PacketCountSummary {
Expand Down

0 comments on commit 61b8b17

Please sign in to comment.