Sys.Linux.Proc.NetDev (Hyper v0.1.0)

Copy Markdown View Source

Parses /proc/net/dev into per-interface byte counters.

The file opens with two header lines and then one line per interface:

Inter-|   Receive  ...                  |  Transmit ...
 face |bytes  packets ...               |bytes  packets ...
enp1s0: 187188513509 68447977 0 ...      112751842436 64224487 0 ...

Each data line is <ifname>: <8 receive counters> <8 transmit counters>, where receive bytes is the 1st counter and transmit bytes is the 9th. Rather than trust the header or assume a fixed column count, a line is taken only if it matches name: <digits...>: the two header rows do not (no name: followed by a number), and an interface name may itself contain a : (an IP alias such as eth0:0), which a naive split on the first colon would mangle.

Every interface is returned as-is - loopback, bridges, docker/veth, and tunnels included. Which interfaces count toward a metric is the caller's policy.

Summary

Functions

Parse a /proc/net/dev payload into one Interface per interface line.

Read and parse /proc/net/dev.

Functions

parse(content)

Parse a /proc/net/dev payload into one Interface per interface line.

read()

@spec read() :: {:ok, [Sys.Linux.Proc.NetDev.Interface.t()]} | {:error, File.posix()}

Read and parse /proc/net/dev.