Module Munin_sys

System monitoring.

Provides stateless, poll-based system metrics sampling and background session monitoring. Each module samples instantaneous or cumulative values from the operating system. CPU, network, and disk I/O statistics are cumulative since boot and require two samples to compute usage percentages; memory statistics are instantaneous.

Platform support

Supported platforms: Linux and macOS. Platform-specific behavior is documented per module. Some metrics have limited availability on certain platforms (e.g., macOS CPU counters populate only user/nice/system/idle fields).

Background monitoring

start spawns a background thread that periodically samples CPU, memory, and process statistics and logs them as scalar metrics via Munin.Session.

Logged metrics (all with sys/ prefix):

System-wide:

  • sys/cpu_user — user CPU percentage (0–100)
  • sys/cpu_system — system CPU percentage (0–100)
  • sys/mem_used_pct — memory usage percentage (0–100)
  • sys/mem_used_gb — memory used in GB

Per-process:

  • sys/proc_cpu_pct — process CPU percentage
  • sys/proc_mem_mb — process resident set size in MB

Disk I/O:

  • sys/disk_read_mbs — disk read rate in MB/s
  • sys/disk_write_mbs — disk write rate in MB/s
  • sys/disk_util_pct — disk utilization percentage

Platform support

Supported platforms: Linux and macOS. Platform-specific behavior is documented per module. Some metrics have limited availability on certain platforms (e.g., macOS CPU counters populate only user/nice/system/idle fields).

Modules

module Cpu : sig ... end

CPU statistics.

module Mem : sig ... end

Memory statistics (instantaneous).

module Net : sig ... end

Network I/O statistics.

module Disk_io : sig ... end

Disk I/O statistics.

module Fs : sig ... end

Filesystem statistics (instantaneous).

module Proc : sig ... end

Process statistics.

System information

val loadavg : unit -> float * float * float

loadavg () returns the 1, 5, and 15 minute load averages.

val uptime : unit -> int64

uptime () returns system uptime in seconds.

Background monitoring

type t

The type for background monitors.

val start : Session.t -> ?interval:float -> unit -> t

start session ~interval () begins periodic system monitoring.

All sys/ metrics are defined with ~summary:`Last so the final sampled value appears in run summaries.

interval defaults to 2.0 seconds. The first sample is taken after one interval. The monitor thread is a daemon thread.

val stop : t -> unit

stop t signals the monitoring thread to exit and blocks until it terminates. Safe to call multiple times.