Skip to main content

Module varlink_unit

Module varlink_unit 

Source
Expand description

Per-unit detail via the io.systemd.Unit varlink API on PID 1’s socket. Unit.List itself exists from systemd v258, but the per-type context sections read here (varlink-service.c, varlink-timer.c) first appear in v261, which is the real minimum. This is what the varlink path uses instead of the per-unit D-Bus property fetches in units.rs.

Unit.List can either stream every unit or answer for one named unit. monitord asks per unit: measured on a test host with 305 units, streaming all of them costs ~92ms and 1.3MB, against ~0.47ms for a single filtered call on a warm connection. Break-even is around 198 units, and monitord wants a handful — the [services] list, the tracked timers, and whichever units need a oneshot type check. The collectors that do want every unit (boot_blame, verify) are served from the metrics stream instead.

systemd omits fields that sit at their default rather than sending a zero, so every mapping below has to restate the default the D-Bus property would have returned. Those defaults are asserted in the tests.

Re-exports§

pub use crate::varlink::manager::MANAGER_SOCKET_PATH;

Structs§

UnitLookup
A connection to PID 1’s unit API that remembers what it has already asked.

Functions§

count_cgroup_processes
Count the processes in a unit’s cgroup, including nested ones.
is_oneshot
Whether a unit is a oneshot service.
map_service_stats
Map a Unit.List reply onto ServiceStats.
map_timer_stats
Map a Unit.List reply onto TimerStats.
timer_triggered_unit
The unit a timer triggers, e.g. “logrotate.service” for “logrotate.timer”.