Skip to main content

parse_net_dev

Function parse_net_dev 

Source
pub fn parse_net_dev(buf: &[u8]) -> NetCounters
Expand description

Parse /proc/net/dev into cumulative host counters.

The file has two header lines, then one line per interface:

 face |bytes    packets errs drop fifo frame compressed multicast|bytes ...
    lo: 1234 12 0 0 0 0 0 0 1234 12 0 0 0 0 0 0
  eth0: 5678 34 0 0 0 0 0 0 5678 34 0 0 0 0 0 0

Note that the interface name and the first counter share a colon-separated field, so the split has to happen before the whitespace tokenisation, not after it. Loopback is skipped: see crate::system::NetCounters.