Search by

umairgul / server-pulse

umairgul

Server and application monitoring for Laravel: CPU, memory, disk, network, services, requests, queries, queues, and exceptions, with a dashboard and alerts.

Package info

github.com/umairgul/server-pulse

pkg:composer/umairgul/server-pulse

Fund package maintenance!

umairgul

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-11-30 14:31 UTC

This package is auto-updated.

Last update: 2026-12-01 06:34:01 UTC


README

Server Pulse

Packagist PHP from Packagist Laravel versions GitHub Workflow Status (main) Total Downloads

Server and application monitoring for Laravel, built for apps running on their own Linux server (a VPS managed with Ploi, Forge, or by hand).

  • Server metrics: CPU, memory and swap, disk, network throughput, load average, uptime, service processes (Nginx, PHP-FPM, MySQL, Redis, Supervisor), and queue backlog, read directly from /proc with no shell commands and no root access.
  • Application metrics: request throughput, response time, 5xx error rate, slow requests and queries, queue jobs, and exceptions.
  • A dashboard with live and historical charts, plus alerts with email notifications and events for any other channel.

Installation

You can install the package via Composer:

composer require umairgul/server-pulse

Publish the configuration file and the migrations, then migrate:

php artisan vendor:publish --tag="server-pulse-config"
php artisan vendor:publish --tag="server-pulse-migrations"
php artisan migrate

The migrations create server_pulse_snapshots (per-minute history), server_pulse_alerts, and server_pulse_events (slow requests and queries, exceptions, failed jobs). If you don't want database history or alerts, set SERVER_PULSE_DATABASE_ENABLED=false and skip the migrations.

Requirements

  • PHP 8.3+ and Laravel 12 or 13
  • Linux, for CPU, memory, network, load, uptime, and service metrics (read from /proc). Disk metrics work on any OS. On other systems the unavailable collectors report an error in the snapshot instead of failing the whole collection.
  • No root privileges and no shell commands are needed.
  • A cache store shared by your web, queue, and collector processes. Redis is recommended; the array store does not persist between processes.
  • Optional: the pcntl extension, so server-pulse:work stops gracefully on SIGTERM.

Usage

Collecting metrics

Server Pulse never collects metrics during a web request. Run the collector in one of two ways.

Option A: a supervised worker (recommended in production). server-pulse:work collects every collection_interval seconds in one long-running process. It stops cleanly on SIGTERM, keeps going when a collection fails, and exits when it passes its memory limit, so your process manager restarts it. With Supervisor (Ploi and Forge call these "daemons"):

[program:server-pulse]
command=php /home/forge/example.com/artisan server-pulse:work
user=forge
autostart=true
autorestart=true
stopwaitsecs=10
stdout_logfile=/home/forge/example.com/storage/logs/server-pulse.log

Or with systemd:

# /etc/systemd/system/server-pulse.service
[Unit]
Description=Server Pulse collector
After=network.target

[Service]
User=www-data
WorkingDirectory=/var/www/example.com
ExecStart=/usr/bin/php artisan server-pulse:work
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target

Restart the worker after each deploy, as you would a queue worker, so it picks up new code and config: supervisorctl restart server-pulse or systemctl restart server-pulse.

Option B: the scheduler. In routes/console.php:

use Illuminate\Support\Facades\Schedule;

Schedule::command('server-pulse:collect')->everyFiveSeconds()->withoutOverlapping();

Sub-minute tasks need the scheduler to keep running for the whole minute. That works with the usual * * * * * php artisan schedule:run cron entry on Laravel 12 and later, but each run boots a fresh PHP process every five seconds. The worker is lighter.

Run only one collector per server. On several servers, give each one its own SERVER_PULSE_SERVER_ID if they share a cache store or database.

Each run stores the latest snapshot in your cache. CPU usage and network throughput are calculated from cumulative counters, so they are null on the very first run and populated from the second run onward.

Run it by hand to compare the readings with top, free -b, df -B1, and ip -s link:

php artisan server-pulse:collect --json

Reading metrics

use ServerPulse\ServerPulse\Facades\ServerPulse;

$snapshot = ServerPulse::latest(); // ?ServerSnapshot

$snapshot?->metric('cpu');    // ['usage_percent' => 12.5, 'cores' => 4]
$snapshot?->metric('memory'); // ['total' => ..., 'available' => ..., 'usage_percent' => 41.2, 'swap_total' => ..., ...]
$snapshot?->errors;           // ['network' => 'Unable to read [/proc/net/dev]...']
Metric Values
cpu usage_percent, cores
memory total, available, used, free, buffers, cached, usage_percent, swap values (bytes)
disk partitions[] with path, total, used, free, usage_percent
network interfaces[] counters, plus rx_bytes_per_second / tx_bytes_per_second
load 1m, 5m, 15m
uptime seconds
services services[] with name, running, processes; queue_workers; total processes
queue connection, queues[] with name and size, total backlog

Dashboard

Visit /server-pulse (route name server-pulse.dashboard) to see:

  • overview cards for CPU, memory, disk, network throughput, load average, uptime, and queue workers
  • charts of CPU, memory, disk, and network over the stored history
  • service status, disk partitions, and network interfaces

The dashboard polls the JSON API every SERVER_PULSE_REFRESH_INTERVAL seconds. It warns you when the latest snapshot is older than three collection intervals, which usually means the scheduler stopped. It uses Blade, Alpine.js, and Chart.js inlined from the package, so there are no assets to publish and nothing loads from a CDN. It follows the system light or dark theme.

The charts show the most recent SERVER_PULSE_HISTORY_POINTS collections (720 by default, one hour at a five-second interval), kept in the same cache store as the latest snapshot.

To customize the markup, publish the views:

php artisan vendor:publish --tag="server-pulse-views"

Database history

Live metrics stay in the cache. Every collection that starts a new minute averages the previous minute's points into one server_pulse_snapshots row (cpu, cpu_max, memory, disk, network_rx, network_tx, load, samples). That's 1,440 rows per server per day instead of 17,280, and rows older than SERVER_PULSE_RETENTION_DAYS are deleted automatically. The dashboard's 6h, 24h, and 7d ranges read from this table.

A database failure, such as missing migrations, is reported to your exception handler and never stops the live metrics from updating.

use ServerPulse\ServerPulse\Models\Snapshot;

Snapshot::query()->where('server_id', 'web-1')->where('collected_at', '>=', now()->subDay())->avg('cpu');

Alerts

Each aggregated minute is compared with the thresholds in config/server-pulse.php:

Metric Warning Critical Compared value
cpu 80% 95% Average CPU for the minute
memory 80% 95% Average memory usage
disk 80% 95% Fullest monitored partition
load off off Average 1-minute load (size it to your core count)
error_rate 5% 15% Share of 5xx responses, for minutes with at least 20 requests

These defaults are examples, not universal rules. Set a level to null to disable it. Because thresholds are checked against minute averages, a five-second spike does not trigger an alert.

An alert stays open while the metric is above its warning threshold. It escalates from warning to critical in place, and resolves when the metric recovers. To receive email, set the recipients (comma-separated):

SERVER_PULSE_ALERT_MAIL=ops@example.com,oncall@example.com

Notifications are queued, so they are sent by your queue worker (or immediately with the sync driver). They're sent when an alert triggers, escalates, or resolves, and as a reminder every SERVER_PULSE_ALERT_COOLDOWN minutes (60 by default) while it stays open. The cooldown also stops a metric hovering around its threshold from sending a new email every minute.

For Slack, Discord, Telegram, or webhooks, listen for the events:

use Illuminate\Support\Facades\Event;
use ServerPulse\ServerPulse\Events\AlertResolved;
use ServerPulse\ServerPulse\Events\AlertTriggered;

Event::listen(function (AlertTriggered $event) {
    // $event->alert->metric, ->severity, ->actual_value, ->threshold, ->server_id
    // $event->escalated is true when a warning became critical
});

Open alerts are listed at the top of the dashboard.

Application monitoring

Server Pulse also records how your Laravel application itself is performing, with no middleware to register:

Signal Recorded
Requests Count, 5xx errors, average response time, and slow requests (≥ SERVER_PULSE_SLOW_REQUEST_MS, default 1000) by route pattern such as GET /users/{user}
Queries Count and slow queries (≥ SERVER_PULSE_SLOW_QUERY_MS, default 500) with the SQL and the application file and line that ran them
Queue jobs Processed, failed, average duration, and failed job classes; backlog of the configured queues
Exceptions Every reported exception, grouped by class and throw site

The dashboard's Application section shows per-minute requests, response time, error rate, queries, jobs, and queue backlog, plus the most frequent slow requests, slow queries, exceptions, and failed jobs for the selected range. It needs database history to be enabled.

How it stays cheap and safe:

  • Metrics are buffered in memory and written once, after the response has been sent, as atomic per-minute cache counters. Use Redis in production.
  • Slow requests and queries, exceptions, and failed jobs are written to server_pulse_events, with at most 20 per request or job.
  • Recording failures, for example Redis or the database being down, are swallowed and never break your application.
  • Routes are stored as URI patterns, never full URLs. SQL keeps its ? placeholders and bindings are never stored, including inside QueryException messages. Set application.exception_messages to false to store exception class names only.
  • On busy applications, set SERVER_PULSE_APM_SAMPLE_RATE (for example 0.1). Counters are scaled up, and slow queries, exceptions, and failed jobs are always recorded.
  • Health checks and tools are ignored by default (up, telescope*, horizon*, _debugbar*), as is the dashboard itself.

An HTTP error-rate alert (5% warning, 15% critical) is checked for minutes with at least 20 requests.

Queue backlog is read from the default queue of the default connection. Configure others on QueueCollector:

Collectors\QueueCollector::class => [
    'enabled' => true,
    'connection' => 'redis',
    'queues' => ['default', 'emails'],
],

Service status

The services collector checks whether processes for Nginx, PHP-FPM, MySQL/MariaDB, Redis, and Supervisor are running, and counts queue worker processes (artisan queue:work and Horizon). It reports that a process exists, not that the service is answering requests. Adjust the process names in config/server-pulse.php:

Collectors\ServicesCollector::class => [
    'enabled' => true,
    'services' => [
        'Nginx' => ['nginx'],
        'PHP-FPM' => ['php-fpm*'],
        'Caddy' => ['caddy'],
    ],
    'queue_workers' => ['artisan queue:work', 'artisan horizon'],
],

Process names are matched against /proc/<pid>/comm, which the kernel truncates to 15 characters, and * wildcards are allowed.

JSON API

The latest snapshot is available at GET /server-pulse/api/metrics (route name server-pulse.metrics):

{ "data": { "server_id": "web-1", "collected_at": "2026-11-30T10:00:00+00:00", "metrics": { ... }, "errors": {} } }

Chart history is available at GET /server-pulse/api/history (route name server-pulse.history). Pass ?since=<unix ms> to receive only newer points:

{ "data": [ { "t": 1764496800000, "cpu": 12.5, "memory": 41.2, "disk": 71.3, "rx": 1384120.5, "tx": 312400.25, "load": 0.52 } ] }

Stored history is available with ?range=6h, 24h, or 7d (downsampled to at most 720 points). Open alerts and those resolved in the last day are available at GET /server-pulse/api/alerts. Application metrics and top events are available at GET /server-pulse/api/application?range=1h (or 6h, 24h, 7d).

All routes use the web and auth middleware and the viewServerPulse gate. By default the gate only allows access in the local environment. Define it in your AppServiceProvider to allow others:

use Illuminate\Support\Facades\Gate;

Gate::define('viewServerPulse', fn (User $user): bool => $user->is_admin);

Configuration

Env variable Default Purpose
SERVER_PULSE_ENABLED true Disables the command and routes when false
SERVER_PULSE_SERVER_ID hostname Namespaces cache keys; must be unique per server
SERVER_PULSE_CACHE_STORE default store Cache store for live metrics (Redis recommended)
SERVER_PULSE_PROC_PATH /proc procfs root, e.g. the host's /proc mounted in a container
SERVER_PULSE_COLLECTION_INTERVAL 5 Seconds between runs; sizes the cache lifetime
SERVER_PULSE_DASHBOARD_ENABLED true Registers the HTTP routes
SERVER_PULSE_PATH server-pulse Route prefix
SERVER_PULSE_REFRESH_INTERVAL 5 Seconds between dashboard polls
SERVER_PULSE_HISTORY_POINTS 720 Number of collections kept for the charts
SERVER_PULSE_DATABASE_ENABLED true Per-minute database history (required for alerts)
SERVER_PULSE_DB_CONNECTION default Database connection for history and alerts
SERVER_PULSE_AGGREGATE_SECONDS 60 Length of each stored period
SERVER_PULSE_RETENTION_DAYS 14 Days of history to keep; 0 keeps everything
SERVER_PULSE_ALERTS_ENABLED true Threshold alerts
SERVER_PULSE_ALERT_MAIL none Comma-separated alert email recipients
SERVER_PULSE_ALERT_COOLDOWN 60 Minutes between reminders; 0 disables reminders
SERVER_PULSE_APM_ENABLED true Application monitoring
SERVER_PULSE_APM_SAMPLE_RATE 1.0 Share of requests and jobs counted
SERVER_PULSE_SLOW_REQUEST_MS 1000 Slow request threshold
SERVER_PULSE_SLOW_QUERY_MS 500 Slow query threshold
SERVER_PULSE_QUEUE_CONNECTION default Queue connection for backlog

Collectors are listed under collectors in config/server-pulse.php. Each one can be disabled there, and some take options: disk paths (default ['/']), network interfaces / ignore (default ignores lo), and the services and queue worker patterns.

Custom collectors

Implement ServerPulse\ServerPulse\Contracts\MetricCollector and register the class in server-pulse.collectors:

use ServerPulse\ServerPulse\Contracts\MetricCollector;

class QueueSizeCollector implements MetricCollector
{
    public function name(): string
    {
        return 'queue';
    }

    public function collect(): array
    {
        return ['default' => Queue::size('default')];
    }
}

A collector that throws is recorded in the snapshot's errors and does not stop the other collectors.

Security

The dashboard and API show details about your infrastructure.

  • Every route requires the auth middleware and the viewServerPulse gate. Until you define the gate, access is only allowed in the local environment. Change the middleware with server-pulse.dashboard.middleware, or turn all routes off with SERVER_PULSE_DASHBOARD_ENABLED=false.
  • Responses are sent with Cache-Control: no-store, X-Frame-Options: DENY, X-Content-Type-Options: nosniff, and Referrer-Policy: same-origin.
  • Environment variables, credentials, process command lines, request URLs and payloads, and SQL bindings are never collected. Exception messages are stored unless you set application.exception_messages to false.
  • Collection needs no root privileges and runs no shell commands. Only the configured disk paths and the configured procfs root are read.
  • The dashboard's scripts are bundled with the package and inlined, so nothing loads from a third-party CDN.

Troubleshooting

Symptom Cause and fix
Dashboard says Stale The collector is not running. Check the worker (supervisorctl status) or the scheduler.
Dashboard returns 403 Define the viewServerPulse gate for non-local environments.
Unable to read [/proc/...] errors Not running on Linux, or /proc is mounted elsewhere (for example in a container); set SERVER_PULSE_PROC_PATH.
CPU usage or network rates are always empty Each collection needs the previous one's counters from the cache. Use a persistent store such as Redis, not array, and keep the collector running.
6h / 24h / 7d ranges or alerts are empty Run the migrations, and check your log for reported database errors. History is written once per minute.
No application metrics The cache store must be shared between web, queue, and collector processes (Redis recommended), and SERVER_PULSE_APM_ENABLED must be on.
No alert emails Set SERVER_PULSE_ALERT_MAIL and run a queue worker (notifications are queued).
Values inside Docker don't match the container's limits /proc shows the host's CPU and memory; container cgroup limits are not applied.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Thank you for considering contributing to Server Pulse! Please review our contributing guide to get started.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

Server Pulse is open-sourced software licensed under the MIT license.