{{-- /admin/health — System Health monitor. One screen for "is everything up?": database, cache, queue, the Node WhatsApp bridge, media storage, the error log, every connected engine, and host vitals. Polls ?format=json to stay live. --}} @php $tone = [ 'up' => ['dot' => 'bg-wa-green', 'text' => 'text-wa-deep', 'bg' => 'bg-wa-mint', 'ring' => 'ring-wa-green/15', 'word' => __('Operational')], 'warn' => ['dot' => 'bg-amber-500', 'text' => 'text-amber-700', 'bg' => 'bg-amber-50', 'ring' => 'ring-amber-500/15', 'word' => __('Degraded')], 'down' => ['dot' => 'bg-red-500', 'text' => 'text-red-700', 'bg' => 'bg-red-50', 'ring' => 'ring-red-500/15', 'word' => __('Down')], 'idle' => ['dot' => 'bg-ink-300', 'text' => 'text-ink-500', 'bg' => 'bg-paper-100', 'ring' => 'ring-ink-500/10', 'word' => __('Idle')], ]; $T = fn($s) => $tone[$s] ?? $tone['idle']; $ov = $T($overall); @endphp {{-- Header --}}
{{ __('Admin') }} {{ __('System Health') }}
{{-- Overall status banner --}}
{{ __('All systems') }} — {{ $ov['word'] }}
{{ __('Last checked') }} {{ now()->format('H:i:s') }} · {{ __('auto-refreshes every 20s') }}
{{-- Last 24h activity --}}
@php $acts = [ ['label' => __('Messages · 24h'), 'value' => $activity['messages'] ?? 0, 'icon' => ''], ['label' => __('AI calls · 24h'), 'value' => $activity['ai_calls'] ?? 0, 'icon' => ''], ['label' => __('Conversations · 24h'), 'value' => $activity['conversations'] ?? 0, 'icon' => ''], ['label' => __('Webhooks · 24h'), 'value' => $activity['webhooks'] ?? 0, 'icon' => ''], ]; @endphp @foreach ($acts as $a)
{!! $a['icon'] !!}
{{ number_format($a['value']) }}
{{ $a['label'] }}
@endforeach
{{-- Core service probes --}}
{{ __('Core services') }}
@foreach ($checks as $key => $c) @php $t = $T($c['state']); @endphp
{{ $c['label'] }}
{{ $t['word'] }}
{{ $c['value'] }}
{{ $c['detail'] }}
{{-- Queue card gets a "Clear pending jobs" button. This app is queue-less (no worker), so any pending jobs are stale broadcasts from an older build that will never run — this wipes them and returns the card to green. --}} @if ($key === 'queue') @endif
@endforeach
{{-- Latency + throughput --}}
{{-- Response-time bars --}}
{{ __('Response time') }}
@php $maxMs = max(1, collect($latency)->max('ms') ?: 1); @endphp @forelse ($latency as $l) @php $lt = $T($l['state']); @endphp
{{ $l['label'] }} {{ $l['ms'] }} ms
@empty
{{ __('No timing data.') }}
@endforelse
{{-- 14-day message throughput --}}
@php $tvals = array_values($throughput['series'] ?? []); $tmax = max(1, count($tvals) ? max($tvals) : 1); $tn = max(1, count($tvals)); $TW = 1000; $TH = 180; $tpts = []; foreach ($tvals as $i => $v) { $x = $tn > 1 ? ($i / ($tn - 1)) * $TW : 0; $y = $TH - ($v / $tmax) * ($TH - 12) - 4; $tpts[] = round($x, 1) . ',' . round($y, 1); } $tline = implode(' ', $tpts); $tarea = $tn > 1 ? "0,{$TH} " . $tline . " {$TW},{$TH}" : ''; @endphp
{{ __('Message throughput · 14 days') }}
{{ __('peak') }} {{ number_format($tmax) }}/{{ __('day') }}
@if (array_sum($tvals) > 0) @if ($tarea)@endif @else
{{ __('No message activity in the last 14 days.') }}
@endif
{{-- Engine / channel health --}}
{{ __('WhatsApp engines & connected numbers') }}
@forelse ($engines as $e) @php $t = $T($e['state']); @endphp
{{ $e['label'] }}
{{ $e['connected'] }} / {{ $e['total'] }}
{{ __('connected of total numbers') }}
@if (!empty($e['breakdown']))
@foreach ($e['breakdown'] as $status => $count) {{ $status }} {{ $count }} @endforeach
@endif
@empty
{{ __('No engines configured yet.') }}
@endforelse
{{-- Host vitals --}}
{{ __('Host vitals') }}
@php $vit = [ ['PHP', $system['php'] ?? '—'], ['Laravel', $system['laravel'] ?? '—'], ['Environment', $system['env'] ?? '—'], ['Debug', $system['debug'] ?? '—'], ['Disk free', $system['disk_free'] ?? '—'], ['Memory limit', $system['memory_limit'] ?? '—'], ]; @endphp @foreach ($vit as [$k, $v])
{{ $k }}
{{ $v }}
@endforeach
@if (isset($system['disk_used_pct']))
{{ __('Disk used') }}{{ $system['disk_used_pct'] }}%
@endif
{{-- Live logs — Laravel + Node, straight from this server --}}
{{ __('Logs') }}

{{ __('Watch the server logs live or download the complete file — no hosting panel needed.') }}

@foreach ([ ['laravel', __('Laravel log'), 'storage/logs/laravel.log', __('Web app, webhooks, campaigns, payments, errors.')], ['node', __('Node log'), 'node/node.log', __('WhatsApp engines, flows, broadcasts sent through Node.')], ] as [$lk, $ll, $lp, $ld]) @php $lpath = \App\Http\Controllers\Admin\LogViewerController::path($lk); @endphp
{{ $ll }} {{ $lp }}
{{ $ld }} @if ($lpath) · {{ number_format(filesize($lpath) / 1048576, 2) }} MB · {{ __('updated') }} {{ \Carbon\Carbon::createFromTimestamp(filemtime($lpath))->diffForHumans() }} @else · {{ __('not found on this server') }} @endif
@if ($lpath) {{ __('Download full file') }} @endif
{{-- Live panel (hidden until "Live log") --}}
@endforeach