karim-tao / laravel-server-status
Current CPU, load, memory, disk, uptime and PHP processes of the server running your Laravel app, as a Livewire component or in code. No daemon, no history, no database.
Package info
github.com/karim-tao/laravel-server-status
pkg:composer/karim-tao/laravel-server-status
Requires
- php: ^8.3
- illuminate/process: ^12.0 || ^13.0
- illuminate/support: ^12.0 || ^13.0
- livewire/livewire: ^3.0 || ^4.0
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.29
- orchestra/testbench: ^10.0 || ^11.0
- pestphp/pest: ^4.4
- pestphp/pest-plugin-type-coverage: ^4.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
A Livewire component that shows the current CPU, load, memory, disk, uptime and PHP processes of the server. Values are read when the page is open, with no daemon and no database.
Add it to a Blade view:
<livewire:server-status />
Or read the values in code:
$snapshot = app(ServerMetrics::class)->read(); $snapshot->cpu; // % $snapshot->memoryUsed; // bytes $snapshot->diskUsed; // bytes
Installation
Requires PHP 8.3+, Laravel 12 or 13 and Livewire 3 or 4.
You can install the package via composer:
composer require karim-tao/laravel-server-status
That's it — the ServerStatusServiceProvider and the server-status Livewire component are auto-discovered, so you're ready to go.
Usage
In your own layout
Embed the component wherever you want, for example in an admin dashboard:
@extends('admin.layout') @section('content') <livewire:server-status /> @endsection
The card refreshes every 5 seconds while it is on screen.
Standalone page
A ready-made page with the card is available too. Route it with the middleware you prefer:
use KarimTao\ServerStatus\Http\Controllers\ServerStatusController; Route::get('/server-status', ServerStatusController::class)->middleware('auth');
Reading the metrics yourself
Everything the card shows comes from ServerMetrics, which you can use on its own — in a command, an API endpoint or a health check:
use KarimTao\ServerStatus\ServerMetrics; $snapshot = app(ServerMetrics::class)->read(); $snapshot->cpu; // percent $snapshot->load; // percents over 1, 5 and 15 minutes $snapshot->cores; // count $snapshot->memoryUsed; // bytes $snapshot->memoryTotal; // bytes $snapshot->diskUsed; // bytes $snapshot->diskTotal; // bytes $snapshot->uptime; // seconds $snapshot->process; // name $snapshot->processes; // count
How it works
- Linux reads
/procandtop. - macOS uses
sysctl,vm_statandtop. - Windows uses PowerShell.
- Disk uses PHP's
disk_total_space()anddisk_free_space(). - Processes counts the processes named like the one serving the request,
php-fpmfor example. - No fallbacks. A value that cannot be read throws
MetricUnavailableException, saying what failed.
Testing
composer test
Each reader is tested on its own system and skipped elsewhere.
License
Laravel Server Status is open-sourced software licensed under the MIT license.
