293 أسطر
3.2 KiB
HTML
293 أسطر
3.2 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 Monitoring Dashboard</title>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
|
|
|
<style>
|
|
|
|
body{
|
|
font-family:Arial,sans-serif;
|
|
background:#f4f6f8;
|
|
margin:30px;
|
|
}
|
|
|
|
h1{
|
|
text-align:center;
|
|
color:#333;
|
|
}
|
|
|
|
.cards{
|
|
display:flex;
|
|
gap:20px;
|
|
margin-bottom:25px;
|
|
}
|
|
|
|
.card{
|
|
flex:1;
|
|
background:white;
|
|
padding:20px;
|
|
border-radius:10px;
|
|
box-shadow:0 2px 6px rgba(0,0,0,.15);
|
|
text-align:center;
|
|
}
|
|
|
|
.card h2{
|
|
margin:0;
|
|
color:#666;
|
|
}
|
|
|
|
.card p{
|
|
font-size:28px;
|
|
margin-top:15px;
|
|
color:#1976d2;
|
|
font-weight:bold;
|
|
}
|
|
|
|
.chart-container{
|
|
background:white;
|
|
padding:20px;
|
|
border-radius:10px;
|
|
box-shadow:0 2px 6px rgba(0,0,0,.15);
|
|
}
|
|
|
|
table{
|
|
|
|
width:100%;
|
|
margin-top:30px;
|
|
border-collapse:collapse;
|
|
background:white;
|
|
box-shadow:0 2px 6px rgba(0,0,0,.15);
|
|
|
|
}
|
|
|
|
th{
|
|
|
|
background:#1976d2;
|
|
color:white;
|
|
padding:10px;
|
|
|
|
}
|
|
|
|
td{
|
|
|
|
text-align:center;
|
|
padding:10px;
|
|
border-bottom:1px solid #ddd;
|
|
|
|
}
|
|
|
|
.up{
|
|
|
|
color:green;
|
|
font-weight:bold;
|
|
|
|
}
|
|
|
|
.down{
|
|
|
|
color:red;
|
|
font-weight:bold;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<h1>Mithal Monitoring Dashboard</h1>
|
|
|
|
<div class="cards">
|
|
|
|
<div class="card">
|
|
|
|
<h2>Uptime (24h)</h2>
|
|
|
|
<p id="uptime">--</p>
|
|
|
|
</div>
|
|
|
|
<div class="card">
|
|
|
|
<h2>SSL Remaining</h2>
|
|
|
|
<p id="ssl">--</p>
|
|
|
|
</div>
|
|
|
|
<div class="card">
|
|
|
|
<h2>Latest Latency</h2>
|
|
|
|
<p id="latency">--</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="chart-container">
|
|
|
|
<canvas id="chart"></canvas>
|
|
|
|
</div>
|
|
|
|
<h2>Last 10 Checks</h2>
|
|
|
|
<table>
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Time</th>
|
|
|
|
<th>Status</th>
|
|
|
|
<th>Latency</th>
|
|
|
|
<th>DNS</th>
|
|
|
|
<th>Search</th>
|
|
|
|
<th>SSL Days</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody id="tableBody">
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
<script>
|
|
|
|
let chart=null;
|
|
|
|
async function refresh(){
|
|
|
|
const response=await fetch("/api/data");
|
|
|
|
const data=await response.json();
|
|
|
|
if(data.length===0)
|
|
return;
|
|
|
|
const last=data[data.length-1];
|
|
|
|
document.getElementById("latency").innerHTML=
|
|
last.latency_ms+" ms";
|
|
|
|
document.getElementById("ssl").innerHTML=
|
|
last.ssl_remaining_days+" days";
|
|
|
|
const success=data.filter(x=>x.uptime).length;
|
|
|
|
const uptime=((success/data.length)*100).toFixed(2);
|
|
|
|
document.getElementById("uptime").innerHTML=
|
|
uptime+"%";
|
|
|
|
const hour=data.slice(-60);
|
|
|
|
const labels=hour.map(x=>x.timestamp.substring(11));
|
|
|
|
const values=hour.map(x=>x.latency_ms);
|
|
|
|
if(chart)
|
|
chart.destroy();
|
|
|
|
chart=new Chart(
|
|
|
|
document.getElementById("chart"),
|
|
|
|
{
|
|
|
|
type:"line",
|
|
|
|
data:{
|
|
|
|
labels:labels,
|
|
|
|
datasets:[{
|
|
|
|
label:"Latency (ms)",
|
|
|
|
data:values,
|
|
|
|
borderWidth:2,
|
|
|
|
fill:false
|
|
|
|
}]
|
|
|
|
},
|
|
|
|
options:{
|
|
|
|
responsive:true,
|
|
|
|
plugins:{
|
|
|
|
legend:{
|
|
display:true
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
const tbody=document.getElementById("tableBody");
|
|
|
|
tbody.innerHTML="";
|
|
|
|
data.slice(-10).reverse().forEach(item=>{
|
|
|
|
tbody.innerHTML+=`
|
|
|
|
<tr>
|
|
|
|
<td>${item.timestamp}</td>
|
|
|
|
<td class="${item.uptime?'up':'down'}">
|
|
|
|
${item.uptime?'UP':'DOWN'}
|
|
|
|
</td>
|
|
|
|
<td>${item.latency_ms} ms</td>
|
|
|
|
<td>${item.dns_ms} ms</td>
|
|
|
|
<td>${item.search_latency_ms} ms</td>
|
|
|
|
<td>${item.ssl_remaining_days}</td>
|
|
|
|
</tr>
|
|
|
|
`;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
refresh();
|
|
|
|
setInterval(refresh,60000);
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|