MCPcopy Create free account
hub / github.com/prometheus/procfs / NetProtocols

Method NetProtocols

net_protocols.go:73–79  ·  view source on GitHub ↗

NetProtocols reads stats from /proc/net/protocols and returns a map of PortocolStatLine entries. As of this writing no official Linux Documentation exists, however the source is fairly self-explanatory and the format seems stable since its introduction in 2.6.12-rc2 Linux 2.6.12-rc2 - https://elixir

()

Source from the content-addressed store, hash-verified

71// Linux 2.6.12-rc2 - https://elixir.bootlin.com/linux/v2.6.12-rc2/source/net/core/sock.c#L1452
72// Linux 5.10 - https://elixir.bootlin.com/linux/v5.10.4/source/net/core/sock.c#L3586
73func (fs FS) NetProtocols() (NetProtocolStats, error) {
74 data, err := util.ReadFileNoStat(fs.proc.Path("net/protocols"))
75 if err != nil {
76 return NetProtocolStats{}, err
77 }
78 return parseNetProtocols(bufio.NewScanner(bytes.NewReader(data)))
79}
80
81func parseNetProtocols(s *bufio.Scanner) (NetProtocolStats, error) {
82 nps := NetProtocolStats{}

Callers 1

Calls 3

ReadFileNoStatFunction · 0.92
parseNetProtocolsFunction · 0.85
PathMethod · 0.45

Tested by 1