sockstat

package
v0.0.0-...-5655933 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: MIT Imports: 13 Imported by: 0

README

Read sockstat info from /proc/net/sockstat and /proc/net/sockstat6

example file

sockets: used 211
TCP: inuse 9 orphan 0 tw 19 alloc 47 mem 22
UDP: inuse 2 mem 0
UDPLITE: inuse 0
RAW: inuse 0
FRAG: inuse 0 memory 0

The content of "/proc/net/sockstat" in a Linux system provides information about the socket usage on the system. The fields and their meaning are as follows:

sockets: used: Total number of used sockets on the system. TCP: inuse: Number of currently established TCP sockets. orphan: Number of orphaned TCP sockets. tw: Number of sockets in TIME_WAIT state. alloc: Number of sockets allocated. mem: Memory used by TCP sockets. UDP: inuse: Number of currently established UDP sockets. mem: Memory used by UDP sockets. UDPLITE: inuse: Number of currently established UDP-Lite sockets. RAW: inuse: Number of currently established raw sockets. FRAG: inuse: Number of currently established fragment sockets. memory: Memory used by fragment sockets. These fields provide a snapshot of the socket usage on the system, including the number of sockets in use and memory usage, which can be useful for monitoring and troubleshooting network issues.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadFileNoStat

func ReadFileNoStat(filename string) ([]byte, error)

ReadFileNoStat uses io.ReadAll to read contents of entire file. This is similar to os.ReadFile but without the call to os.Stat, because many files in /proc and /sys report incorrect file sizes (either 0 or 4096). Reads a max file size of 1024kB. For files larger than this, a scanner should be used.

Types

type NetSockstat

type NetSockstat struct {
	// Used is non-nil for IPv4 sockstat results, but nil for IPv6.
	Used      *int
	Protocols []NetSockstatProtocol
}

A NetSockstat contains the output of /proc/net/sockstat{,6} for IPv4 or IPv6, respectively.

func ParseNetSockstat

func ParseNetSockstat() (*NetSockstat, error)

ParseNetSockstat retrieves IPv4 socket statistics.

func ParseNetSockstat6

func ParseNetSockstat6() (*NetSockstat, error)

ParseNetSockstat6 retrieves IPv6 socket statistics.

If IPv6 is disabled on this kernel, the returned error can be checked with os.IsNotExist.

type NetSockstatProtocol

type NetSockstatProtocol struct {
	Protocol string
	InUse    int
	Orphan   *int
	TW       *int
	Alloc    *int
	Mem      *int
	Memory   *int
}

A NetSockstatProtocol contains statistics about a given socket protocol. Pointer fields indicate that the value may or may not be present on any given protocol.

type SockStat

type SockStat struct {
	config.PluginConfig

	Protocols []string `toml:"protocols"`
}

func (*SockStat) Clone

func (s *SockStat) Clone() inputs.Input

func (*SockStat) Gather

func (ss *SockStat) Gather(slist *types.SampleList)

func (*SockStat) Name

func (s *SockStat) Name() string

Jump to

Keyboard shortcuts

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