Module Munin_sys.Net

Network I/O statistics.

type t = {
  1. bytes_rx : int64;
    (*

    Total bytes received.

    *)
  2. packets_rx : int64;
    (*

    Total packets received.

    *)
  3. bytes_tx : int64;
    (*

    Total bytes transmitted.

    *)
  4. packets_tx : int64;
    (*

    Total packets transmitted.

    *)
}

Cumulative network I/O counters since boot.

Aggregates all network interfaces except loopback. Counters are cumulative and monotonically increasing (until system reboot or counter overflow).

type stats = {
  1. rx_bytes_per_sec : float;
    (*

    Receive rate in bytes per second.

    *)
  2. rx_packets_per_sec : float;
    (*

    Receive rate in packets per second.

    *)
  3. tx_bytes_per_sec : float;
    (*

    Transmit rate in bytes per second.

    *)
  4. tx_packets_per_sec : float;
    (*

    Transmit rate in packets per second.

    *)
}

Network I/O rates computed between two samples.

val sample : unit -> t

sample () returns cumulative network I/O counters.

  • raises Sys_error

    if network statistics are unavailable on the current platform or an error occurs during sampling.

val compute : prev:t -> next:t -> dt:float -> stats

compute ~prev ~next ~dt calculates network I/O rates between two samples.

Computes the delta for each counter and divides by dt to obtain rates per second. Negative deltas (e.g., from counter overflow or reboot) are treated as zero.

  • raises Invalid_argument

    if dt <= 0.0.