82 lines
2.9 KiB
PHP
82 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Ui\System;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Support\Facades\Cache;
|
|
use Livewire\Component;
|
|
|
|
class ServicesCard extends Component
|
|
{
|
|
public array $services = [];
|
|
public array $servicesCompact = [];
|
|
|
|
// Mapping für schöne Labels/Hints
|
|
protected array $nameMap = [
|
|
// Mail
|
|
'postfix' => ['label' => 'Postfix', 'hint' => 'MTA / Versand'],
|
|
'dovecot' => ['label' => 'Dovecot', 'hint' => 'IMAP / POP3'],
|
|
'rspamd' => ['label' => 'Rspamd', 'hint' => 'Spamfilter'],
|
|
'clamav' => ['label' => 'ClamAV', 'hint' => 'Virenscanner'],
|
|
|
|
// Daten & Cache
|
|
'db' => ['label' => 'Datenbank', 'hint' => 'MySQL / MariaDB'],
|
|
'127.0.0.1:6379' => ['label' => 'Redis', 'hint' => 'Cache / Queue'],
|
|
|
|
// Web / PHP
|
|
'php8.2-fpm' => ['label' => 'PHP-FPM', 'hint' => 'PHP Runtime'],
|
|
'nginx' => ['label' => 'Nginx', 'hint' => 'Webserver'],
|
|
|
|
// MailWolt
|
|
'mailwolt-queue' => ['label' => 'MailWolt Queue', 'hint' => 'Job Worker'],
|
|
'mailwolt-schedule'=> ['label' => 'MailWolt Schedule', 'hint' => 'Task Scheduler'],
|
|
'mailwolt-ws' => ['label' => 'MailWolt WebSocket','hint' => 'Echtzeit Updates'],
|
|
|
|
// Sonstiges
|
|
'fail2ban' => ['label' => 'Fail2Ban', 'hint' => 'SSH / Mail Protection'],
|
|
'systemd-journald'=> ['label' => 'System Logs', 'hint' => 'Journal'],
|
|
'rsyslog' => ['label' => 'Rsyslog', 'hint' => 'Logging'],
|
|
|
|
// WebSocket/TCP
|
|
'127.0.0.1:8080' => ['label' => 'Reverb', 'hint' => 'WebSocket Server'],
|
|
];
|
|
|
|
public function mount(): void
|
|
{
|
|
$this->load();
|
|
}
|
|
|
|
public function load(): void
|
|
{
|
|
$this->services = Cache::get('health:services', []);
|
|
$meta = Cache::get('health:meta', []);
|
|
$updated = $meta['updated_at'] ?? null;
|
|
|
|
$existing = collect($this->services)->keyBy('name');
|
|
|
|
$this->servicesCompact = collect($this->nameMap)
|
|
->map(function ($meta, $key) use ($existing) {
|
|
$srv = $existing->get($key, []);
|
|
$ok = (bool)($srv['ok'] ?? false);
|
|
|
|
return [
|
|
'label' => $meta['label'],
|
|
'hint' => $meta['hint'],
|
|
'ok' => $ok,
|
|
'dotClass' => $ok ? 'bg-emerald-400' : 'bg-rose-400',
|
|
'pillText' => $ok ? 'Aktiv' : 'Offline',
|
|
'pillClass' => $ok
|
|
? 'text-emerald-300 border-emerald-400/30 bg-emerald-500/10'
|
|
: 'text-rose-300 border-rose-400/30 bg-rose-500/10',
|
|
];
|
|
})
|
|
->values()
|
|
->all();
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.ui.system.services-card');
|
|
}
|
|
}
|