Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ these configuration options:
* **Filter:** BPF filter for this socket. If this is set, testimony will
guarantee that the socket passed to child processes has this filter locked
in such a way that clients cannot remove it.
* **NumberOfClients:** Use this option to specify the expected number of
clients to connect to the socket.

### Wire Protocol ###

Expand Down
1 change: 1 addition & 0 deletions go/testimonyd/internal/socket/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type SocketConfig struct {
FanoutID int // fanout id to avoid conflicts
User, Group string // user/group to provide the socket to (will chown it)
Filter string // BPF filter to apply to this socket
NumberOfClients int // Number of clients testimony working with
}

func (s SocketConfig) uid() (int, error) {
Expand Down
20 changes: 15 additions & 5 deletions go/testimonyd/internal/socket/socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func newSocket(sc SocketConfig, fanoutID int, num int) (*socket, error) {

// String returns a unique string for this socket.
func (s *socket) String() string {
return fmt.Sprintf("[S:%v:%v]", s.conf.SocketName, s.num)
return fmt.Sprintf("[S:%v; fid:%v]", s.conf.SocketName, s.num)
}

// getNewBlocks is a goroutine that watches for new available packet blocks,
Expand Down Expand Up @@ -149,12 +149,22 @@ func (s *socket) reportStats() {
if err != nil {
log.Printf("error getting statistics: %v", err)
} else {
totalPackets += uint64(stats.tp_packets)
totalDrops += uint64(stats.tp_drops)
vlog.V(1, "%v stats: %d packets (%.02fpps), %d drops (%.02fpps) (%.02f%% dropped) since last log, %d packets, %d drops total (%.02f%% dropped)", s,
stats.tp_packets, float64(stats.tp_packets)/seconds, stats.tp_drops, float64(stats.tp_drops)/seconds, float64(stats.tp_drops)/float64(stats.tp_drops+stats.tp_packets)*100,
client_status := "delivered to client"
if len(s.currentConns) <= 0 {
client_status = "discarded by testimony"
}
if s.conf.NumberOfClients == 0 {
vlog.V(1, "%v stats: connected - %d clients", s, len(s.currentConns))
} else {
vlog.V(1, "%v stats: connected - %d clients, still not connected - %d, therefore %v packets loosed for each unconnected client", s, len(s.currentConns), s.conf.NumberOfClients-len(s.currentConns), stats.tp_packets)
}
vlog.V(1, " %v stats: %d packets %v (%.02fpps), %d dropped in kernel (%.02fpps) (%.02f%% dropped) since last log, %d packets, %d drops total (%.02f%% dropped)",
s, stats.tp_packets, client_status, float64(stats.tp_packets)/seconds,
stats.tp_drops, float64(stats.tp_drops)/seconds,
float64(stats.tp_drops)/float64(stats.tp_drops+stats.tp_packets)*100,
totalPackets, totalDrops, float64(totalDrops)/float64(totalPackets+totalDrops)*100)
}

}
}

Expand Down