package kaun-board

  1. Overview
  2. Docs

Module Sysstat.Disk_ioSource

Disk I/O statistics.

Sourcetype t = {
  1. bytes_read : int64;
    (*

    Total bytes read from disk.

    *)
  2. bytes_written : int64;
    (*

    Total bytes written to disk.

    *)
  3. time_ms : int64;
    (*

    Cumulative I/O time in milliseconds.

    *)
  4. num_disks : int64;
    (*

    Number of physical disks included in aggregation.

    *)
}

Cumulative disk I/O counters since boot.

Aggregates physical disks only, excluding virtual devices, partitions, and metadata devices. Counters are cumulative and monotonically increasing until system reboot.

Platform behavior:

  • Linux: Excludes virtual devices (dm-*, loop*, md*, zram*) and partitions (detected by prefix matching the parent device name).
Sourcetype stats = {
  1. read_bytes_per_sec : float;
    (*

    Read rate in bytes per second.

    *)
  2. write_bytes_per_sec : float;
    (*

    Write rate in bytes per second.

    *)
  3. utilization_percent : float;
    (*

    Disk utilization percentage (0.0 to 100.0).

    *)
}

Disk I/O rates and utilization computed between two samples.

Sourceval sample : unit -> t

sample () returns cumulative disk I/O counters.

Only physical disks are included; partitions and virtual devices are excluded.

  • raises Sys_error

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

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

compute ~prev ~next ~dt calculates disk I/O rates and utilization between two samples.

Computes the delta for each counter and divides by dt to obtain rates per second. Utilization is calculated as (time_delta / (dt * 1000 * num_disks)) * 100, representing the percentage of time disks were actively performing I/O, capped at 100.0.

If num_disks is 0L, utilization_percent is 0.0.