Skip to main content

sample_network_rate

Function sample_network_rate 

Source
pub fn sample_network_rate(pid: i32) -> Option<(u64, u64)>
Expand description

Sample RX/TX bytes per second for the process’s network namespace.

The sampling window is controlled by the PEEK_NET_SAMPLE_MS environment variable:

  • If unset, a default of 1000ms (1s) is used.
  • If set to 0, rate sampling is skipped and None is returned.
  • Otherwise, the value is interpreted as a window in milliseconds.

Returns (rx_bytes_per_sec, tx_bytes_per_sec).