Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

System Metrics Laravel Package

cboxdk/system-metrics

Get real-time system metrics from Linux and macOS in pure PHP. No extensions or dependencies—just type-safe, readonly classes covering CPU, memory, storage, network, load, uptime, and container metrics with explicit Result-based error handling.

View on GitHub
Deep Wiki
Context7
v3.1.0

Added

  • Memory working set for containers. ContainerLimits::$memoryWorkingSetBytes reports cgroup memory usage minus inactive file cache, the way cAdvisor and Kubernetes define the working set: memory.current - inactive_file on cgroup v2, memory.usage_in_bytes - total_inactive_file on v1, floored at 0. Raw usage counts reclaimable page cache, so a container that writes files reads as close to its limit even though the kernel would hand that memory back. memoryWorkingSetUtilizationPercentage() and availableMemoryBytesFromWorkingSet() go with it. All three are null when memory.stat cannot be read. memoryUsageBytes and its helpers are unchanged, and so is limits().

Fixed

  • limits() in a cgroup without a memory limit pairs host total with host usage. It used to pair the host's total with the usage of only the processes inside the cgroup — every systemd service, and every container whose limit sits on a parent cgroup (a Kubernetes pod or ECS task limit). availableMemoryBytes() and memoryUtilization() described neither scope, and a capacity planner built on them over-packed the machine. Cgroups with a limit are unchanged. (#10)
  • cgroup v1 oomKillCount counts OOM kills. It read the under_oom flag, which is 1 only while the cgroup is stalled with the OOM killer disabled, so it stayed 0 however many processes the kernel killed. It now reads the oom_kill counter in memory.oom_control (Linux 4.13+), and is null on older kernels. cgroup v2 is unchanged. (#11)

Thanks to @Orrison for #10 and #11.

v3.0.0

Breaking Changes

  • SystemLimits::$cpuCores: Changed from int to float to support fractional CPU quotas (e.g. 200m = 0.2 cores, 1500m = 1.5 cores).
  • SystemLimits::$currentCpuCores: Changed from int to float.
  • SystemLimits::availableCpuCores(): Now returns float instead of int.
  • SystemLimits::canScaleCpu(): Parameter changed from int to float.
  • ContainerLimits::cpuUtilizationPercentage(): No longer capped at 100%. Can exceed 100% during over-quota burst scenarios.
  • ContainerLimits::memoryUtilizationPercentage(): No longer capped at 100%.

Bug Fixes

  • Fix CPU limit using headroom instead of quota: CompositeSystemLimitsSource was using availableCpuCores() (quota − usage) to populate the cpuCores limit field. Now uses cpuQuota directly. Same fix for memory.
  • Fix delta-based CPU usage sampling permanently broken: CompositeContainerMetricsSource created a new LinuxCgroupMetricsSource on every read(), resetting the parser's delta cache. cpuUsageCores was always null. The source is now persisted.
  • Fix fractional CPU precision loss: Removed (int) ceil() casts that rounded cgroup quotas to whole cores.

Migration Guide

// Before (v2.x)
$cores = $limits->cpuCores;        // int: 1, 2, 4, 8

// After (v3.0)
$cores = $limits->cpuCores;        // float: 0.2, 1.5, 4.0, 8.0

Closes #6

Full Changelog: https://github.com/cboxdk/system-metrics/compare/v2.3.1...v3.0.0

v2.3.1

Bug Fixes

  • Rewrite container detection with allowlist strategy: Replaced fragile cgroup path heuristics with a clean allowlist approach. Only known container indicators trigger detection: sentinel files (/.dockerenv, /run/.containerenv), PID 1 environment (container= for LXC/nspawn), and cgroup keywords (kubepods, docker, containerd, crio, lxc). No more false positives on VMs with systemd and cgroup v2.
  • Fix OS version showing "unknown": Use PRETTY_NAME as primary OS name. Fall back through VERSION_ID → VERSION → BUILD_ID for version. Use kernel release as final fallback instead of "unknown".
  • Added LXC detection via cgroup keywords.

Full Changelog: https://github.com/cboxdk/system-metrics/compare/v2.3.0...v2.3.1

v2.3.0

Bug Fixes

  • Fix false positive container detection on VMs with cgroup v2: Modern Linux (Ubuntu 22.04+, Debian 12+) enables cgroup v2 by default even on bare metal and VMs. The container detection now correctly identifies VMs by checking the cgroup path — root cgroup / means VM/bare metal, non-root scope means container.
  • SystemOverviewAction: Only populates the container field when environment detection confirms insideContainer is true.
  • LinuxEnvironmentDetector: Added /proc/1/environ check for systemd container markers (LXC/nspawn). Added cgroup v2 path heuristic for container scope detection.

Deprecations

  • SystemLimits::isContainerized(): Deprecated. Use SystemMetrics::environment()->containerization->insideContainer for accurate container detection.

Full Changelog: https://github.com/cboxdk/system-metrics/compare/v2.2.0...v2.3.0

v2.2.0

Testing support with fake sources for all metric types. See CHANGELOG.md for details.

v2.0.1

What's Changed

Performance

  • Command Caching: Added static caching to ProcessRunner::commandExists to eliminate redundant shell execution checks (~1-5ms savings per call)
  • Parsing Optimization: Replaced regex splitting with explode in LinuxProcStatParser and LinuxProcPidStatParser for reduced CPU overhead

Documentation

  • Link Fixes: Fixed internal documentation links to include .md extension for correct navigation on Cbox.dk and GitHub
  • Rebranding: Updated documentation URLs and references from PHPeek to Cbox

Full Changelog: https://github.com/cboxdk/system-metrics/compare/v2.0.0...v2.0.1

v2.0.0

Breaking Changes

  • Namespace Changed: PHPeek\SystemMetrics → Cbox\SystemMetrics
  • Package Renamed: gophpeek/system-metrics → cboxdk/system-metrics

Migration Guide

Update your composer.json:

composer remove gophpeek/system-metrics
composer require cboxdk/system-metrics

Update your imports:

// Before
use PHPeek\SystemMetrics\SystemMetrics;

// After
use Cbox\SystemMetrics\SystemMetrics;

Full Changelog: https://github.com/cboxdk/system-metrics/compare/v1.6.0...v2.0.0

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
oxygen/data
oxygen/core
jengo/base
xiloryx/log-collector
a21ns1g4ts/filament-stripe
la-php/laravel-admin
artisan-build/community-prompts
vleroy/smart
ayles-software/laravel-australian-public-holidays
cboxdk/laravel-id-spatie
cboxdk/laravel-id-billing
cboxdk/laravel-id-billing-bridge
simple-as-fuck/php-performance-log
hsluv/hsluv
seampact/codegen
seampact/hooks
seampact/ir
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table