sockstatlog

package
v1.46.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2023 License: BSD-3-Clause Imports: 18 Imported by: 2

Documentation

Overview

Package sockstatlog provides a logger for capturing network socket stats for debugging. Stats are collected at a frequency of 10 Hz and logged to disk. Stats are only uploaded to the log server on demand.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SockstatLogID added in v1.40.0

func SockstatLogID(logID logid.PublicID) logid.PrivateID

SockstatLogID reproducibly derives a new logid.PrivateID for sockstat logging from a node's public backend log ID. The returned PrivateID is the sha256 sum of logID + "sockstat". If a node's public log ID becomes known, it is trivial to spoof sockstat logs for that node. Given that this is just for debugging, we're not too concerned about that.

Types

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger logs statistics about network sockets.

func NewLogger

func NewLogger(logdir string, logf logger.Logf, logID logid.PublicID, netMon *netmon.Monitor) (*Logger, error)

NewLogger returns a new Logger that will store stats in logdir. On platforms that do not support sockstat logging, a nil Logger will be returned. The returned Logger is not yet enabled, and must be shut down with Shutdown when it is no longer needed. Logs will be uploaded to the log server using a new log ID derived from the provided backend logID. The netMon parameter is optional; if non-nil it's used to do faster interface lookups.

func (*Logger) Flush added in v1.40.0

func (l *Logger) Flush()

Flush sends pending logs to the log server and flushes them from the local buffer.

func (*Logger) LogID added in v1.40.0

func (l *Logger) LogID() string

func (*Logger) SetLoggingEnabled added in v1.40.0

func (l *Logger) SetLoggingEnabled(v bool)

SetLoggingEnabled enables or disables logging. When disabled, socket stats are not polled and no new logs are written to disk. Existing logs can still be fetched via the C2N API.

func (*Logger) Shutdown

func (l *Logger) Shutdown()

func (*Logger) Write added in v1.40.0

func (l *Logger) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL