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

Laravel System Resources Laravel Package

stepanenko3/laravel-system-resources

Laravel System Resources gives your app a simple way to monitor server health, exposing CPU, memory, disk, and load metrics through a clean API and dashboard so you can spot bottlenecks early and keep your application running smoothly in production.

View on GitHub
Deep Wiki
Context7

Getting Started

Install the package and let Laravel auto-discover the service provider:

composer require stepanenko3/laravel-system-resources
php artisan vendor:publish --tag=system-resources-config

Look first at config/system-resources.php — that's where you control which probes run (CPU load, memory, disk) and whether the HTTP route is registered. Then check the package's routes/ directory (or php artisan route:list | grep -i resource) to see the exact URI and middleware applied out of the box.

First use case: hit the JSON endpoint from your ops dashboard or an uptime monitor to get a cheap server-health snapshot without installing Prometheus:

curl -s https://yourapp.test/system-resources | jq

If the route is disabled by default, resolve the underlying class directly instead:

use Stepanenko3\SystemResources\SystemResources;

return SystemResources::make()->all(); // or ->cpu(), ->memory(), ->disk()

Implementation Patterns

Dashboard polling. Point a small Vue/React widget at the endpoint on a 10–30s interval. Because each call may shell out for metrics, wrap it in Cache::remember('sys-resources', 15, ...) at the controller level rather than hitting the package on every request.

Scheduled health logging. Use a scheduled command to persist metrics for trend lines, which is far more useful than a live snapshot:

Schedule::call(function () {
    SystemResourceLog::create(SystemResources::make()->all());
})->everyFiveMinutes();

Guarding the route. Always place the endpoint behind auth + an admin gate, or restrict by IP in config/system-resources.php. A public metrics endpoint leaks hostnames, disk paths, and load characteristics — treat it as internal-only and prefer registering it on an internal-only route group.

Alerting integration. Return the array into your existing notification pipeline (Slack, Mail, Healthchecks) and threshold on disk.used_percent or memory.used_percent rather than raw bytes — absolute numbers don't port between hosts.

Multi-server fan-out. If you run several nodes, the package only reports the host it executes on. Either expose the endpoint per-node behind a shared secret and aggregate centrally, or run the scheduled-logger pattern and ship rows to a central store.

Blade/Direct access. For a quick internal admin page, inject the class into a controller and pass the array to the view; no need to consume your own HTTP endpoint.

Gotchas and Tips

  • v1.1.1 is a patch release with no documented changes in the changelog beyond the compare diff. Treat it as a safe in-place bump from v1.1.0, but read the actual commit diff before upgrading if you depend on exact output keys.
  • Platform assumptions. System metric collection on Linux typically shells out to commands or reads /proc; Windows and containerized environments frequently return zeros, null, or throw. Validate output on your actual runtime image before wiring it into alerts.
  • exec() may be disabled. Shared hosting and hardened PHP-FPM configs often have disable_functions=exec,shell_exec. If metrics come back empty, that's the first thing to check — not the package config.
  • Permission and container quirks. In Docker, disk numbers reflect the container's overlay filesystem, not the host. Mounted volumes and cgroup memory limits can make memory.total misleading.
  • Config caching. After editing config/system-resources.php, run php artisan config:clear (or config:cache in deploy) — a stale cached config is the usual cause of "my change did nothing."
  • Cost of polling. A system-resources call per page-load per user adds up. Cache aggressively; metrics don't need sub-second freshness.
  • Extension point. If the built-in probes miss something (GPU, queue depth, Redis memory), subclass or decorate the resource class in a small service provider rather than forking the package — keeps future patch upgrades (like this one) painless.
  • Don't assert on exact values in tests. Mock or bind a fake implementation of the resource class in your test container; real CPU/disk values are non-deterministic and will flake CI.
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.
skyraptor/chatter
edlugz/sasapay
abbasudo/artisan-route
mirvan/ippanel
ignibyte/aic-framework
glavweb/data-schema-bundle
glavweb/datagrid-bundle
tacticmedia/scim-server
uni-method/frame
neika-ai/sdk
adachsoft/php-code-style
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
adachsoft/api-version-bundle
cgv/localized-resource