115 أسطر
4.3 KiB
HTML
115 أسطر
4.3 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Mithal Engine Status</title>
|
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
|
<style>
|
|
body { font-family: system-ui, sans-serif; background: #f4f4f5; margin: 0; padding: 20px; color: #18181b; }
|
|
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; margin-bottom: 20px; }
|
|
.card { background: white; padding: 20px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
|
|
.metric { font-size: 2rem; font-weight: bold; color: #2563eb; }
|
|
table { width: 100%; border-collapse: collapse; margin-top: 10px; }
|
|
th, td { text-align: left; padding: 12px; border-bottom: 1px solid #e4e4e7; }
|
|
.status-up { color: #16a34a; font-weight: bold; }
|
|
.status-down { color: #dc2626; font-weight: bold; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<h1>Mithal Engine Monitoring Dashboard</h1>
|
|
|
|
<div class="grid">
|
|
<div class="card">
|
|
<h3>Uptime (Last 24h)</h3>
|
|
<div class="metric" id="uptime-indicator">--%</div>
|
|
</div>
|
|
<div class="card">
|
|
<h3>SSL Certificate</h3>
|
|
<div class="metric" id="ssl-status">-- Days</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card" style="margin-bottom: 20px;">
|
|
<h3>Response Time (Last Hour)</h3>
|
|
<canvas id="latencyChart" height="80"></canvas>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<h3>Recent Logs (Last 10 Checks)</h3>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Timestamp</th>
|
|
<th>Status</th>
|
|
<th>Latency (s)</th>
|
|
<th>DNS (s)</th>
|
|
<th>Search (s)</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="log-table"></tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<script>
|
|
async function loadData() {
|
|
const response = await fetch('data.csv');
|
|
const text = await response.text();
|
|
|
|
// Parse CSV
|
|
const rows = text.trim().split('\n').slice(1).map(row => {
|
|
const [timestamp, status, latency, ssl_days, dns, search] = row.split(',');
|
|
return { timestamp, status: parseInt(status), latency: parseFloat(latency), ssl_days, dns, search };
|
|
});
|
|
|
|
if (rows.length === 0) return;
|
|
|
|
// Uptime Calculation
|
|
const upChecks = rows.filter(r => r.status >= 200 && r.status < 400).length;
|
|
const uptimePct = ((upChecks / rows.length) * 100).toFixed(2);
|
|
document.getElementById('uptime-indicator').textContent = `${uptimePct}%`;
|
|
|
|
// SSL Status
|
|
const latest = rows[rows.length - 1];
|
|
document.getElementById('ssl-status').textContent = `${latest.ssl_days} Days`;
|
|
|
|
// Chart Data (Last 60 entries = 1 hour)
|
|
const recentHour = rows.slice(-60);
|
|
const labels = recentHour.map(r => new Date(r.timestamp).toLocaleTimeString());
|
|
const data = recentHour.map(r => r.latency);
|
|
|
|
new Chart(document.getElementById('latencyChart'), {
|
|
type: 'line',
|
|
data: {
|
|
labels: labels,
|
|
datasets: [{
|
|
label: 'Latency (s)',
|
|
data: data,
|
|
borderColor: '#2563eb',
|
|
tension: 0.1,
|
|
fill: false
|
|
}]
|
|
},
|
|
options: { animation: false }
|
|
});
|
|
|
|
// Logs Table (Last 10)
|
|
const last10 = rows.slice(-10).reverse();
|
|
const tbody = document.getElementById('log-table');
|
|
tbody.innerHTML = last10.map(r => `
|
|
<tr>
|
|
<td>${new Date(r.timestamp).toLocaleString()}</td>
|
|
<td class="${r.status === 200 ? 'status-up' : 'status-down'}">${r.status}</td>
|
|
<td>${r.latency.toFixed(3)}</td>
|
|
<td>${parseFloat(r.dns).toFixed(3)}</td>
|
|
<td>${parseFloat(r.search).toFixed(3)}</td>
|
|
</tr>
|
|
`).join('');
|
|
}
|
|
|
|
loadData();
|
|
setInterval(loadData, 60000); // Refresh every minute
|
|
</script>
|
|
</body>
|
|
</html> |