Fix: optionale Dienste (ClamAV) immer live prüfen statt Monit-Cache
Monit-Cache wurde jede Minute neu befüllt mit altem Status. Optionale Dienste werden jetzt direkt via systemctl geprüft. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>main v1.1.344
parent
7ccc7921c1
commit
aaccb4bb32
|
|
@ -75,25 +75,40 @@ class Dashboard extends Component
|
|||
|
||||
private function loadServices(): array
|
||||
{
|
||||
// 1) Monit-Cache (populated by RunHealthChecks job)
|
||||
$cached = Cache::get(CacheVer::k('health:services'), []);
|
||||
$rows = $cached['rows'] ?? [];
|
||||
$allCards = config('woltguard.cards', []);
|
||||
$dashKeys = config('woltguard.dashboard', array_keys($allCards));
|
||||
|
||||
// 2) Fallback: nur die Dashboard-Teilmenge aus woltguard.php (aktive Probes)
|
||||
if (empty($rows)) {
|
||||
$allCards = config('woltguard.cards', []);
|
||||
$dashKeys = config('woltguard.dashboard', array_keys($allCards));
|
||||
foreach ($dashKeys as $key) {
|
||||
$card = $allCards[$key] ?? null;
|
||||
if (!$card) continue;
|
||||
$isOk = false;
|
||||
foreach ($card['sources'] as $src) {
|
||||
if ($this->probeSource($src)) { $isOk = true; break; }
|
||||
}
|
||||
// Optionale Dienste (z.B. ClamAV) nur anzeigen wenn aktiv
|
||||
if (!$isOk && ($card['optional'] ?? false)) continue;
|
||||
$rows[] = ['label' => $card['label'], 'hint' => $card['hint'], 'ok' => $isOk];
|
||||
// 1) Monit-Cache für nicht-optionale Dienste
|
||||
$cached = Cache::get(CacheVer::k('health:services'), []);
|
||||
$monitRows = $cached['rows'] ?? [];
|
||||
$monitIndex = [];
|
||||
foreach ($monitRows as $r) {
|
||||
$monitIndex[strtolower($r['name'] ?? '')] = $r;
|
||||
}
|
||||
|
||||
$rows = [];
|
||||
foreach ($dashKeys as $key) {
|
||||
$card = $allCards[$key] ?? null;
|
||||
if (!$card) continue;
|
||||
$optional = $card['optional'] ?? false;
|
||||
|
||||
// Optionale Dienste (z.B. ClamAV) immer live prüfen – Monit-Cache kann veraltet sein
|
||||
if (!$optional && isset($monitIndex[strtolower($card['label'] ?? '')])) {
|
||||
$rows[] = $monitIndex[strtolower($card['label'])];
|
||||
continue;
|
||||
}
|
||||
|
||||
$isOk = false;
|
||||
foreach ($card['sources'] as $src) {
|
||||
if ($this->probeSource($src)) { $isOk = true; break; }
|
||||
}
|
||||
if (!$isOk && $optional) continue;
|
||||
$rows[] = ['label' => $card['label'], 'hint' => $card['hint'], 'ok' => $isOk];
|
||||
}
|
||||
|
||||
// Fallback: wenn gar keine Daten, alle live proben
|
||||
if (empty($rows) && !empty($monitRows)) {
|
||||
$rows = $monitRows;
|
||||
}
|
||||
|
||||
return array_map(fn($r) => [
|
||||
|
|
|
|||
Loading…
Reference in New Issue