System Metrics
Real-time system metrics from Linux and macOS in pure PHP. CPU, memory, storage, network, and container metrics with no extensions or dependencies.
System Metrics reads CPU, memory, storage, network, and process data directly from /proc and /sys on Linux, and from sysctl/vm_stat on macOS. No PHP extensions, no Composer dependencies, no C bindings. One require and it works everywhere PHP runs.
Pure PHP, Full Visibility
Container Aware
Reads cgroup v1 and v2 limits instead of host resources. Reports 85% memory usage (of container limit) instead of the misleading 0.7% (of host RAM).
Zero Dependencies
No ext-posix, no ext-sysinfo, no Composer packages. Pure PHP 8.3 with readonly classes and immutable DTOs.
CPU Metrics
Raw counters, per-core data, and usage percentage via delta snapshots. Works in containers with CPU limit awareness.
Memory Metrics
Physical RAM, swap, buffers, cache, and available memory. Container-aware with cgroup limit detection.
Result Pattern
Every operation returns Result
PHPStan Level 9
Maximum static analysis coverage with 89.9% test coverage. Type-safe from the ground up.
Why this matters in containers
When your container has 512MB memory but the host has 64GB, standard PHP functions like memory_get_usage() show the PHP process memory, not the container usage. And /proc/meminfo shows the host. System Metrics reads the cgroup memory limit and current usage, giving you the real picture of your container resource consumption.
Not a monitoring agent
System Metrics is a library, not a daemon. It reads metrics on demand when your code asks for them. For continuous monitoring, pair it with Laravel Queue Metrics or your own collection loop.
Resources
From the Blog
Zero-Dependency System Metrics in Pure PHP
Why I built a system metrics library with no extensions, no Composer dependencies, and no C bindings. Reading /proc and
Your PHP Container Metrics Are Lying to You
Most monitoring tools report host resources instead of container limits. When your container has 512MB but the host has