Spaces:
Running
Running
File size: 11,938 Bytes
09f0702 68aa291 09f0702 68aa291 09f0702 68aa291 09f0702 68aa291 09f0702 68aa291 09f0702 68aa291 09f0702 68aa291 09f0702 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>System Status | Live Monitor</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&family=JetBrains+Mono:wght@400;700&display=swap" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
<style>
:root {
--bg-color: #0b0f19;
--card-bg: rgba(23, 32, 51, 0.7);
--border-color: rgba(255, 255, 255, 0.1);
--accent-green: #10b981;
--accent-red: #ef4444;
--text-muted: #94a3b8;
}
body {
background-color: var(--bg-color);
background-image:
radial-gradient(at 0% 0%, rgba(16, 185, 129, 0.1) 0px, transparent 50%),
radial-gradient(at 100% 100%, rgba(59, 130, 246, 0.1) 0px, transparent 50%);
color: #fff;
font-family: 'Inter', sans-serif;
min-height: 100vh;
-webkit-font-smoothing: antialiased;
}
/* --- Header Stats --- */
.stats-bar {
background: rgba(255,255,255,0.03);
border-bottom: 1px solid var(--border-color);
padding: 15px 0;
margin-bottom: 40px;
backdrop-filter: blur(10px);
}
.stat-item {
border-right: 1px solid var(--border-color);
}
.stat-item:last-child { border-right: none; }
.stat-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }
.stat-value { font-family: 'JetBrains Mono', monospace; font-size: 1.2rem; font-weight: 700; }
/* --- Cards --- */
.monitor-card {
background: var(--card-bg);
border: 1px solid var(--border-color);
border-radius: 12px;
padding: 24px;
transition: all 0.3s ease;
position: relative;
overflow: hidden;
backdrop-filter: blur(12px);
}
.monitor-card:hover {
transform: translateY(-5px);
border-color: rgba(255, 255, 255, 0.2);
box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}
/* --- Typography & Elements --- */
h5 { font-weight: 600; font-size: 1.1rem; margin: 0; }
.mono-text { font-family: 'JetBrains Mono', monospace; font-size: 0.85rem; color: var(--text-muted); }
/* --- Status Indicators --- */
.status-dot {
height: 10px;
width: 10px;
border-radius: 50%;
display: inline-block;
margin-right: 8px;
}
.status-online {
background-color: var(--accent-green);
box-shadow: 0 0 10px var(--accent-green);
animation: pulse-green 2s infinite;
}
.status-offline {
background-color: var(--accent-red);
box-shadow: 0 0 10px var(--accent-red);
animation: pulse-red 2s infinite;
}
@keyframes pulse-green {
0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}
@keyframes pulse-red {
0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
/* --- Progress Bar --- */
.reliability-track {
height: 6px;
background: rgba(255,255,255,0.1);
border-radius: 3px;
margin-top: 15px;
margin-bottom: 8px;
overflow: hidden;
}
.reliability-bar {
height: 100%;
border-radius: 3px;
transition: width 0.5s ease;
}
/* --- Loading Skeleton --- */
.skeleton {
background: linear-gradient(90deg, #1f2937 25%, #374151 50%, #1f2937 75%);
background-size: 200% 100%;
animation: loading 1.5s infinite;
border-radius: 4px;
color: transparent !important;
}
@keyframes loading {
0% { background-position: 200% 0; }
100% { background-position: -200% 0; }
}
</style>
</head>
<body>
<div class="stats-bar sticky-top">
<div class="container">
<div class="row align-items-center">
<div class="col-md-4 mb-2 mb-md-0">
<div class="d-flex align-items-center gap-2">
<i class="bi bi-activity text-primary fs-4"></i>
<h4 class="m-0 fw-bold">Uptime<span class="text-primary">Monitor</span></h4>
</div>
</div>
<div class="col-md-8">
<div class="row text-center text-md-end">
<div class="col-4 stat-item">
<div class="stat-label">System Uptime</div>
<div class="stat-value text-white" id="server-uptime">--:--:--</div>
</div>
<div class="col-4 stat-item">
<div class="stat-label">Active Monitors</div>
<div class="stat-value text-info" id="monitor-count">-</div>
</div>
<div class="col-4 stat-item">
<div class="stat-label">Server Time</div>
<div class="stat-value text-warning" id="server-time">--:--</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="container pb-5">
<div class="d-flex justify-content-between align-items-end mb-4">
<div>
<h2 class="fw-bold mb-1">Service Status</h2>
<p class="text-muted m-0">Real-time performance metrics</p>
</div>
<div class="text-end">
<span class="badge bg-dark border border-secondary text-secondary" id="last-updated">
<i class="bi bi-arrow-repeat spin"></i> Connecting...
</span>
</div>
</div>
<div class="row g-4" id="cards-container">
<div class="col-md-6 col-lg-4"><div class="monitor-card skeleton" style="height: 200px"></div></div>
<div class="col-md-6 col-lg-4"><div class="monitor-card skeleton" style="height: 200px"></div></div>
<div class="col-md-6 col-lg-4"><div class="monitor-card skeleton" style="height: 200px"></div></div>
</div>
</div>
<script>
// Helper to format seconds into H:M:S
function formatDuration(seconds) {
const h = Math.floor(seconds / 3600);
const m = Math.floor((seconds % 3600) / 60);
const s = Math.floor(seconds % 60);
return `${h}h ${m}m ${s}s`;
}
// Helper to calculate percentage
function calcPercentage(success, fail) {
const total = success + fail;
if (total === 0) return 100;
return ((success / total) * 100).toFixed(1);
}
async function loadStatus() {
try {
const res = await fetch("/status");
const data = await res.json();
// 1. Update Header Stats
document.getElementById("server-uptime").innerText = formatDuration(data.uptimeSeconds);
document.getElementById("server-time").innerText = data.serverTime;
document.getElementById("monitor-count").innerText = Object.keys(data.targets).length;
const now = new Date();
document.getElementById("last-updated").innerHTML =
`<i class="bi bi-check-circle-fill text-success"></i> Updated: ${now.toLocaleTimeString()}`;
// 2. Build Cards
const container = document.getElementById("cards-container");
let html = "";
Object.values(data.targets).forEach(t => {
const isOnline = t.lastStatus === "online";
const statusClass = isOnline ? "status-online" : "status-offline";
const statusText = isOnline ? "Operational" : "Downtime Detected";
const badgeColor = isOnline ? "text-success" : "text-danger";
// Calculate reliability
const percent = calcPercentage(t.success, t.fail);
const barColor = percent > 90 ? 'bg-success' : (percent > 50 ? 'bg-warning' : 'bg-danger');
html += `
<div class="col-md-6 col-lg-4">
<div class="monitor-card">
<div class="d-flex justify-content-between align-items-start mb-3">
<div class="d-flex align-items-center">
<span class="status-dot ${statusClass}"></span>
<div>
<h5 class="text-truncate" style="max-width: 200px;" title="${t.url}">${t.url}</h5>
<small class="${badgeColor} fw-bold" style="font-size: 0.75rem;">${statusText}</small>
</div>
</div>
<span class="badge bg-dark border border-secondary text-muted font-monospace">
HTTP/2
</span>
</div>
<div class="d-flex justify-content-between align-items-end">
<span class="text-muted" style="font-size: 0.8rem">Reliability</span>
<span class="fw-bold ${badgeColor}">${percent}%</span>
</div>
<div class="reliability-track">
<div class="reliability-bar ${barColor}" style="width: ${percent}%"></div>
</div>
<hr class="border-secondary opacity-25 my-3">
<div class="row text-center">
<div class="col-4 border-end border-secondary border-opacity-25">
<div class="d-block text-muted" style="font-size: 0.7rem">SUCCESS</div>
<div class="fw-bold text-white">${t.success}</div>
</div>
<div class="col-4 border-end border-secondary border-opacity-25">
<div class="d-block text-muted" style="font-size: 0.7rem">FAILED</div>
<div class="fw-bold text-danger">${t.fail}</div>
</div>
<div class="col-4">
<div class="d-block text-muted" style="font-size: 0.7rem">LAST PING</div>
<div class="mono-text text-white">${t.lastPing ? t.lastPing.split(' ')[1] : 'N/A'}</div>
</div>
</div>
</div>
</div>
`;
});
container.innerHTML = html;
} catch (error) {
console.error("Fetch error:", error);
document.getElementById("last-updated").innerHTML =
`<i class="bi bi-exclamation-triangle-fill text-danger"></i> Connection Lost`;
}
}
// Initial load
loadStatus();
// Poll every 5 seconds
setInterval(loadStatus, 5000);
</script>
</body>
</html> |