count('tx_vitec_ssrpurgelog', 'crdate > ' . $d1); $purges7d = $this->count('tx_vitec_ssrpurgelog', 'crdate > ' . $d7); $failed7d = $this->count('tx_vitec_ssrpurgelog', 'crdate > ' . $d7 . ' AND success = 0'); $full7d = $this->count('tx_vitec_ssrpurgelog', "crdate > " . $d7 . " AND paths = '*'"); $samples24h = $this->count('tx_vitec_ssrhealthlog', 'crdate > ' . $d1); $ok24h = $this->count('tx_vitec_ssrhealthlog', 'crdate > ' . $d1 . ' AND ok = 1'); $uptime = $samples24h > 0 ? round($ok24h / $samples24h * 100, 1) . ' %' : '-'; $avgMs = $this->scalar('SELECT ROUND(AVG(response_ms)) FROM tx_vitec_ssrhealthlog WHERE crdate > ' . $d1 . ' AND ok = 1'); $maxCache = $this->scalar('SELECT MAX(cache_mb) FROM tx_vitec_ssrhealthlog WHERE crdate > ' . $d7); $rows = [ ['Purges (24 h / 7 Tage)', $purges24h . ' / ' . $purges7d], ['davon Komplett-Purges (7 T.)', (string)$full7d], ['Fehlgeschlagene Purges (7 T.)', $failed7d > 0 ? '' . $failed7d . '' : '0'], ['Verfügbarkeit (24 h)', htmlspecialchars($uptime) . ' (' . $ok24h . '/' . $samples24h . ' Messungen)'], ['∅ Antwortzeit (24 h)', $avgMs !== null ? $avgMs . ' ms' : '-'], ['Max. Cache-Größe (7 T.)', $maxCache !== null ? $maxCache . ' MB' : '-'], ]; $html = ''; foreach ($rows as [$label, $value]) { $html .= ''; } $html .= '
' . $label . '' . $value . '
'; if ($samples24h === 0) { $html .= '

Noch keine Messwerte: Scheduler-Task für vitec:ssr-health einrichten (z. B. alle 5 Minuten).

'; } return $html; } public function getOptions(): array { return []; } private function count(string $table, string $where): int { try { return (int)$this->connectionPool->getConnectionForTable($table) ->executeQuery('SELECT COUNT(*) FROM ' . $table . ' WHERE ' . $where)->fetchOne(); } catch (\Throwable) { return 0; } } private function scalar(string $sql): ?string { try { $v = $this->connectionPool->getConnectionForTable('tx_vitec_ssrhealthlog') ->executeQuery($sql)->fetchOne(); return $v === null || $v === false ? null : (string)$v; } catch (\Throwable) { return null; } } }