# sys-lib v0.4.0 - Live Readings
**What the machine is doing right now, inside a container or not.** v0.4.0 ships memory and swap with container limits, CPU usage and load, disks and disk I/O rates, network interfaces, traffic and connections, pressure and out-of-memory events, and this process's memory, CPU time, threads, open files, and limits. Every scalar reading and every sampler step allocates nothing once warmed up.
## What is sys-lib?
<strong>sys-lib</strong> answers the questions a program asks about the machine it runs on, with one plain function call each, on Linux, macOS, and Windows: the operating system and distribution, the CPU, memory, disks, network interfaces and traffic, the host, this process, virtualization and containers, power, and an application-scoped device id. It also carries the boot kit a long-running service needs in its first milliseconds: build info, instance info, and a process guard. It is container-aware, reports unknown facts as unknown, never runs another program, never starts a thread, and has no third-party runtime dependencies.
## What's in 0.4.0
```toml
[dependencies]
sys = { package = "sys-lib", version = "0.4" }
```
- **`mem`**: `total()`, `used()`, `free()` and their percentages, `snapshot()`, `limit()`, `swap()`, `pressure()`, `events()` (out-of-memory kills), `activity()` and `mem::Sampler` (swap and paging rates), and `huge_pages()`. Inside a cgroup v1 or v2 container, or a Windows job object with a memory limit, the totals are the container's; `host_total()` and `host_free()` give the machine's. LXCFS mounts are recognised, so a limit is never applied twice.
- **`cpu`**: `usage()` over a 100 ms window, `cpu::Sampler` for the total and each core (`sample_per_core_into` writes into a caller's buffer), `load()`, `count()`, `online()`, `packages()`, `quota()`, `frequency()`, `current_frequency()`, `pressure()`, and the instruction-set features with `has()`, `features()`, and `x86_level()`.
- **`disk`**: `space(path)`, `list()` and `list_with()` (kind, filesystem, mount point, space, read-only, network and removable flags), and I/O rates through `io()`, `disk::IoSampler`, `io_totals()`, and `io_counters()`, counting whole disks only so partitions are never counted twice.
- **`net`**: `interfaces()` with addresses, MAC, kind, speed, and MTU; `totals()`, `counters()`, `traffic()`, `net::Sampler`; and `connections()`.
- **`process`**: `parent_id()`, `memory()`, `peak_memory()`, `memory_detail()`, `cpu_time()`, `threads()`, `open_files()`, `limits()`, `started_at()`, `io()`, `info()`, and `process::CpuSampler`.
- **`host`**: `uptime()`, `boot_time()`, `processes()`, and `open_files()`.
- **`Pressure`** with a `Normal`, `Warning`, or `Critical` level from the kernel's stall figures; **`Rate`** ("12.4 MiB/s", or bits with `.bits()`) and **`Mhz`**.
- A `monitor` example that prints a live view built on the samplers.
## How it was tested
- **Allocation-free steady state**, proven by a counting global allocator: every scalar reading and every sampler step allocates nothing after warm-up.
- **Real containers in CI**: the test binary runs under `docker run --memory=256m --cpus=1.5 --cpuset-cpus=0-1`, and the readings must match the limits.
- **Fixture machines recaptured** with the live-reading files: WSL 2, a systemd scope with a nested cgroup v2 limit, Docker on cgroup v2 and on a real cgroup v1 host, and a minimal scratch container. The recapture found a real bug: on a hybrid host the v1 memory controller was missed.
- **Attack tests T5 to T8** over a hostile `/proc` and `/sys` tree: oversized, endless, truncated, and lying files. They found an uptime value that panicked the duration conversion, now reported as malformed.
- **Live comparison** on every CI runner against the OS's own tools: `free`, `df`, and a shell's reading of `/proc` on Linux; `sysctl` and `df` on macOS; CIM and .NET on Windows.
- **A new fuzz target** for the procfs parsers, on every push and nightly, beside Miri over the parsers.
## What changed
- `process::memory_detail()` and `cpu::x86_level()` arrive now instead of in 0.5 (D-044, D-052).
- WSL's `rootfs` mount is no longer listed as a disk (D-050).
- Windows per-core usage on machines with more than 64 logical processors or several processor groups is `Unsupported`, while the total stays correct; Windows paging activity is `Unsupported` (D-047, D-049).
- `docs/API.md` and `docs/SOURCES.md` were corrected to the shipped behaviour on each OS (D-053).
## What's next
`0.5.0`, detection and identity: form factor, virtualization and the cloud vendor, power and batteries, how the program was started, DNS servers, clock synchronization, firmware and the hardware model, and the application-scoped device id.