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); // Browser-side errors reported via POST /api/vitec/client-error // (ClientErrorMiddleware); details in the VITEC SSR module. $clientErrors24h = $this->count('tx_vitec_clienterrorlog', 'crdate > ' . $d1); $clientErrors7d = $this->count('tx_vitec_clienterrorlog', 'crdate > ' . $d7); $rows = [ ['Purges (24 h / 7 days)', $purges24h . ' / ' . $purges7d], ['of which full purges (7 d)', (string)$full7d], ['Failed purges (7 d)', $failed7d > 0 ? '' . $failed7d . '' : '0'], ['Availability (24 h)', htmlspecialchars($uptime) . ' (' . $ok24h . '/' . $samples24h . ' samples)'], ['Avg. response time (24 h)', $avgMs !== null ? $avgMs . ' ms' : '-'], ['Max. cache size (7 d)', $maxCache !== null ? $maxCache . ' MB' : '-'], ['Client errors reported (24 h / 7 d)', ($clientErrors24h > 0 ? '' . $clientErrors24h . '' : '0') . ' / ' . $clientErrors7d], ]; $html = ''; foreach ($rows as [$label, $value]) { $html .= ''; } $html .= '
' . $label . '' . $value . '
'; if ($samples24h === 0) { $html .= '

No samples yet: the cron job for vitec:ssr-health fills this every 5 minutes.

'; } 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; } } }