Skip to main content

update_unit_stats

Function update_unit_stats 

Source
pub async fn update_unit_stats(
    config: Arc<Config>,
    connection: Connection,
    locked_machine_stats: Arc<RwLock<MachineStats>>,
    fs_root: String,
) -> Result<()>
Expand description

Async wrapper that can update unit stats when passed a locked struct. fs_root is prepended to filesystem paths for unit file stats — empty string for the host, /proc/<pid>/root for containers.

The whole (potentially hundreds-of-D-Bus-calls) collection runs before the write lock is taken, not while holding it: locked_machine_stats is shared by every collector, so holding it across the entire per-unit loop would block every other collector’s own (often much quicker) write until this collection finished.