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.
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()
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.
/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.memory.total misleading.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."system-resources call per page-load per user adds up. Cache aggressively; metrics don't need sub-second freshness.How can I help you explore Laravel packages today?