nmbrs-host 0.7.3

Host readings for nmbrs: CPU, memory, disks, network, pressure, processes, control groups and directory sizes
Documentation
// Copyright 2024-2026 Jonathan Shook
// SPDX-License-Identifier: Apache-2.0

//! Readings of the host nmbrs runs on (SRD-118 ยง9).
//!
//! The session sampler (`sysmon=`) and the `host` adapter both read
//! the host through this crate, so each subsystem is read and parsed
//! in one place.
//!
//! - [`category`]: the subsystems' names and what each needs of this
//!   host.
//! - [`cpu`], [`mem`], [`disk`], [`net`], [`pressure`], [`process`],
//!   [`cgroup`]: each subsystem's counters, the parser of its files,
//!   and the arithmetic between two readings.
//! - [`snapshot`]: one reading of chosen categories, as named measures.
//! - [`du`]: the disk space a directory takes.
//!
//! The parsers take text, so the arithmetic is tested on fixtures;
//! only the `read_*` functions, the watchers of a process or a control
//! group, and the directory walk touch the filesystem.

pub mod category;
pub mod cgroup;
pub mod cpu;
pub mod disk;
pub mod du;
pub mod mem;
pub mod net;
pub mod pressure;
pub mod process;
pub mod snapshot;

/// True when `name` can name a watched process or control group: one
/// or more letters, digits, `_` and `-`. The name becomes a label
/// value.
pub(crate) fn is_subject_name(name: &str) -> bool {
    !name.is_empty()
        && name
            .chars()
            .all(|c| c.is_ascii_alphanumeric() || c == '_' || c == '-')
}