hamzi/corewatch
CoreWatch is a zero-dependency DevOps dashboard for Laravel that reads /proc directly to monitor CPU, RAM, and disk, streams huge logs with O(1) memory, runs whitelisted commands safely, sends alerts, and exposes a health endpoint.
Installation:
composer require hamzi/corewatch
php artisan vendor:publish --provider="Hamzi\CoreWatch\CoreWatchServiceProvider" --tag="corewatch-config"
php artisan migrate
Run the doctor first (v2.2.0):
php artisan corewatch:doctor
This is now the fastest way to confirm the package is wired correctly. It checks System, Database, Cache, Queue, Scheduler, Alerts, and Security, and prints a pass/fail summary per area. Anything red here is the actual root cause of a broken dashboard or silent alerts — check it before touching config.
First Use Case:
/corewatch (or /admin/corewatch with Filament).php artisan corewatch:test-alert
It walks you through Slack/Telegram delivery and gives feedback on the failure if the message doesn't arrive.Quick Start:
php artisan corewatch:install
php artisan corewatch:doctor
php artisan corewatch:doctor — replaces guessing for Queue/Scheduler/Alerts issues./corewatch (or /admin/corewatch for Filament).config/corewatch.php (routes, middleware, thresholds, notifications_queue).storage/logs/corewatch.log for package-level errors. Since v2.2.0 catches \Throwable, failures are logged rather than thrown — this file is where they surface.use Hamzi\CoreWatch\Facades\CoreWatch;
$results = CoreWatch::doctor()->run();
$report = CoreWatch::doctor()->run();
if (! $report->passes()) {
Log::critical('CoreWatch diagnostics failed', $report->toArray());
}
php artisan corewatch:doctor || exit 1
Process facade.
CoreWatch::metrics()->fetch(); // Manual refresh
CoreWatch::extend('custom_metric', function () {
return ['value' => app('cache')->stats()['memory_usage']['used_memory']];
});
Echo.channel('corewatch.logs').listen('LogEvent', (e) => console.log(e.message));
config/corewatch.php:
'log' => [
'channels' => ['single', 'daily'],
'levels' => ['error', 'critical'],
],
'alerts' => [
'cpu' => ['threshold' => 90, 'notify' => ['email', 'slack']],
'memory' => ['threshold' => 80, 'cooldown' => 300],
],
SendQueuedAlertJob (ShouldQueue, with backoff retries). Control the queue in .env:
COREWATCH_NOTIFICATIONS_QUEUE=notifications
queue:work won't pick up a dedicated queue name:
php artisan queue:work --queue=notifications,default
event(new \Hamzi\CoreWatch\Events\AlertTriggered('custom_alert', 'Database connection failed'));
CoreWatch::ops()->execute('php artisan queue:work --once');
Route::middleware(['corewatch.auth', 'corewatch.roles:admin'])->group(function () {
// Safe ops routes
});
use Hamzi\CoreWatch\Filament\Widgets\CoreWatchMetrics;
public function getWidgets(): array {
return [CoreWatchMetrics::class];
}
\Throwable handling, the app won't crash to tell you. Add a doctor check or Horizon supervisor for the notifications queue.sync queue in local/test. QUEUE_CONNECTION=sync still works for alert delivery, but you lose the backoff/retry semantics, so don't rely on it as a production test.corewatch:doctor per node in your deploy pipeline.COREWATCH_NOTIFICATIONS_QUEUE, start a worker on that queue, and run php artisan corewatch:test-alert to prove delivery end-to-end.\Throwable handling hides bugs. Collectors, controllers, repositories, and actions now catch \Throwable instead of \Exception. Fatal errors, type errors, and memory exhaustion no longer bubble up — always check storage/logs/corewatch.log and run corewatch:doctor before assuming a metric is simply unavailable./corewatch/logs fails. In tests:
CoreWatch::shouldReceive('broadcastLog')->andReturnTrue();
www-data). Use chmod +x for scripts and gate everything behind corewatch.roles.metrics_interval = 60 seconds and tune from there.config/corewatch.php; debug via storage/logs/corewatch.log.'routes' => ['prefix' => 'admin/corewatch'],
php artisan corewatch:test-alert
It gives diagnostic feedback on the webhook/credentials step rather than a generic failure.'debug' => env('COREWATCH_DEBUG', false),
php artisan corewatch:clear-cache
php artisan queue:failed
php artisan queue:retry all
Hamzi\CoreWatch\Contracts\MetricProvider and register it under 'providers' in config/corewatch.php.CoreWatch::extendAlertChannel('discord', function ($alert) {
// Send to Discord webhook
});
If you extend a channel, make it queue-aware — throw on failure so SendQueuedAlertJob's backoff retries actually trigger.CoreWatch::doctor()->run() returns a structured report — feed it to your own Slack notifier, uptime monitor, or /health endpoint instead of parsing CLI output.resources/views/vendor/corewatch/.CoreWatch::metrics()->raw() and CoreWatch::logs()->recent(100) for custom endpoints.COREWATCH_* overrides config/corewatch.php; COREWATCH_NOTIFICATIONS_QUEUE is the new one to set explicitly.corewatch.auth before web to protect routes:
Route::middleware(['corewatch.auth', 'web'])->group(...);
retention_days defaults to 30 in the migrations — adjust and re-publish if you need longer history.How can I help you explore Laravel packages today?