reckon_db_resource_monitor (reckon_db v5.10.3)

View Source

System resource sampling for reckon-db (CPU + disk).

A node-wide singleton gen_server that samples host CPU and disk usage on a fixed interval and emits telemetry gauges — unlike reckon_db_memory, which fires only when a pressure LEVEL changes, this emits a fresh sample every tick so consumers can graph a live series.

Telemetry (see reckon_db_telemetry.hrl):

  • [reckon_db, cpu, sample] — measurements busy_percent, load1, load5, load15; metadata cores.
  • [reckon_db, disk, sample] — one per mount; measurements used_percent, total_kb, available_kb; metadata mount, data_dir_mount.

CPU/disk come from cpu_sup/disksup (os_mon). The monitor tries to start os_mon on init and DEGRADES GRACEFULLY if it can't: get_stats/0 reports os_mon => false and no CPU/disk telemetry is emitted (there is no pure-BEAM fallback for host CPU% or disk usage). Started from reckon_db_sup when resource_monitoring is enabled (the default).

Summary

Functions

Latest sampled resource snapshot: #{os_mon => boolean(), cpu => map()|undefined, disk => [map()], last_sample => ms}.

Force an immediate sample and return the fresh snapshot.

Start the monitor. Config keys: interval (ms, default 10000), data_dir (string; the store data root, to flag its mount — resolved from the configured stores when omitted).

Functions

code_change(OldVsn, State, Extra)

get_stats()

-spec get_stats() -> map().

Latest sampled resource snapshot: #{os_mon => boolean(), cpu => map()|undefined, disk => [map()], last_sample => ms}.

handle_call(Req, From, State)

handle_cast(Msg, State)

handle_info(Info, State)

init(Config)

sample_now()

-spec sample_now() -> map().

Force an immediate sample and return the fresh snapshot.

start_link()

-spec start_link() -> {ok, pid()} | {error, term()}.

start_link(Config)

-spec start_link(map()) -> {ok, pid()} | {error, term()}.

Start the monitor. Config keys: interval (ms, default 10000), data_dir (string; the store data root, to flag its mount — resolved from the configured stores when omitted).

terminate(Reason, State)