184 أسطر
5.6 KiB
HTML
184 أسطر
5.6 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.space - Status Dashboard</title>
|
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
|
<style>
|
|
body {
|
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
background-color: #f4f7f6;
|
|
margin: 0;
|
|
padding: 20px;
|
|
color: #333;
|
|
}
|
|
.container {
|
|
max-width: 1000px;
|
|
margin: auto;
|
|
}
|
|
h1 {
|
|
text-align: center;
|
|
color: #2c3e50;
|
|
}
|
|
.cards {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
margin-bottom: 20px;
|
|
}
|
|
.card {
|
|
background: #fff;
|
|
padding: 20px;
|
|
border-radius: 8px;
|
|
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
|
width: 48%;
|
|
text-align: center;
|
|
}
|
|
.card h2 {
|
|
margin: 0;
|
|
font-size: 1.2rem;
|
|
color: #7f8c8d;
|
|
}
|
|
.card .value {
|
|
font-size: 2.5rem;
|
|
font-weight: bold;
|
|
color: #27ae60;
|
|
margin-top: 10px;
|
|
}
|
|
.chart-container {
|
|
background: #fff;
|
|
padding: 20px;
|
|
border-radius: 8px;
|
|
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
|
margin-bottom: 20px;
|
|
}
|
|
table {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
background: #fff;
|
|
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
|
border-radius: 8px;
|
|
overflow: hidden;
|
|
}
|
|
th, td {
|
|
padding: 12px 15px;
|
|
text-align: left;
|
|
border-bottom: 1px solid #ddd;
|
|
}
|
|
th {
|
|
background-color: #2c3e50;
|
|
color: #fff;
|
|
}
|
|
tr:hover {
|
|
background-color: #f1f1f1;
|
|
}
|
|
.status-up { color: #27ae60; font-weight: bold; }
|
|
.status-down { color: #e74c3c; font-weight: bold; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<div class="container">
|
|
<h1>mithal.space Monitoring Dashboard</h1>
|
|
|
|
<div class="cards">
|
|
<div class="card">
|
|
<h2>Uptime (Last 24h)</h2>
|
|
<div class="value" id="uptime-val">--%</div>
|
|
</div>
|
|
<div class="card">
|
|
<h2>SSL Certificate Expiry</h2>
|
|
<div class="value" id="ssl-val" style="color: #2980b9;">-- Days</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="chart-container">
|
|
<h2>Latency (Last Hour)</h2>
|
|
<canvas id="latencyChart"></canvas>
|
|
</div>
|
|
|
|
<h2>Recent Checks (Last 10)</h2>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Timestamp</th>
|
|
<th>Status</th>
|
|
<th>HTTP Latency</th>
|
|
<th>Search Latency</th>
|
|
<th>DNS Latency</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="log-body">
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<script>
|
|
async function loadDashboard() {
|
|
try {
|
|
const response = await fetch('metrics.json');
|
|
const data = await response.json();
|
|
|
|
if (data.length === 0) return;
|
|
|
|
const upCount = data.filter(d => d.uptime_status === 'Up').length;
|
|
const uptimePct = ((upCount / data.length) * 100).toFixed(2);
|
|
document.getElementById('uptime-val').innerText = uptimePct + '%';
|
|
|
|
const latestRecord = data[data.length - 1];
|
|
document.getElementById('ssl-val').innerText = latestRecord.ssl_days_left + ' Days';
|
|
|
|
const lastHourData = data.slice(-60);
|
|
const labels = lastHourData.map(d => d.timestamp.split(' ')[1]); // Extract time only
|
|
const latencyData = lastHourData.map(d => d.latency_ms);
|
|
|
|
const ctx = document.getElementById('latencyChart').getContext('2d');
|
|
new Chart(ctx, {
|
|
type: 'line',
|
|
data: {
|
|
labels: labels,
|
|
datasets: [{
|
|
label: 'Response Time (ms)',
|
|
data: latencyData,
|
|
borderColor: '#e67e22',
|
|
backgroundColor: 'rgba(230, 126, 34, 0.2)',
|
|
borderWidth: 2,
|
|
fill: true,
|
|
tension: 0.3
|
|
}]
|
|
},
|
|
options: {
|
|
responsive: true,
|
|
scales: {
|
|
y: { beginAtZero: true }
|
|
}
|
|
}
|
|
});
|
|
|
|
const last10 = data.slice(-10).reverse();
|
|
let tableRows = '';
|
|
last10.forEach(row => {
|
|
const statusClass = row.uptime_status === 'Up' ? 'status-up' : 'status-down';
|
|
tableRows += `
|
|
<tr>
|
|
<td>${row.timestamp}</td>
|
|
<td class="${statusClass}">${row.uptime_status}</td>
|
|
<td>${row.latency_ms} ms</td>
|
|
<td>${row.search_latency_ms} ms</td>
|
|
<td>${row.dns_latency_ms} ms</td>
|
|
</tr>
|
|
`;
|
|
});
|
|
document.getElementById('log-body').innerHTML = tableRows;
|
|
|
|
} catch (error) {
|
|
console.error('Error fetching data:', error);
|
|
document.getElementById('log-body').innerHTML = '<tr><td colspan="5" style="text-align:center; color:red;">No data available yet. Run the Python script first!</td></tr>';
|
|
}
|
|
}
|
|
|
|
window.onload = loadDashboard;
|
|
</script>
|
|
|
|
</body>
|
|
</html> |