الملفات
ghaymah-exam-MohamedSaleh-SRE/q5-mithal-monitor/dashboard.html
root 05edcc3fce Q5
2026-07-27 03:14:09 +00:00

265 أسطر
3.5 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>
*{
margin:0;
padding:0;
box-sizing:border-box;
font-family:Arial,Helvetica,sans-serif;
}
body{
background:#f4f6f9;
padding:30px;
}
h1{
text-align:center;
margin-bottom:30px;
color:#2c3e50;
}
.cards{
display:grid;
grid-template-columns:repeat(auto-fit,minmax(230px,1fr));
gap:20px;
margin-bottom:30px;
}
.card{
background:white;
border-radius:10px;
padding:20px;
box-shadow:0 3px 8px rgba(0,0,0,.15);
}
.card h3{
color:#555;
margin-bottom:10px;
}
.value{
font-size:30px;
font-weight:bold;
color:#007BFF;
}
table{
width:100%;
border-collapse:collapse;
background:white;
margin-top:30px;
box-shadow:0 3px 8px rgba(0,0,0,.15);
}
table th{
background:#007BFF;
color:white;
padding:12px;
}
table td{
padding:10px;
text-align:center;
border-bottom:1px solid #ddd;
}
canvas{
background:white;
margin-top:30px;
padding:20px;
border-radius:10px;
box-shadow:0 3px 8px rgba(0,0,0,.15);
}
.good{
color:green;
font-weight:bold;
}
.bad{
color:red;
font-weight:bold;
}
</style>
</head>
<body>
<h1>🚀 Mithal Monitoring Dashboard</h1>
<div class="cards">
<div class="card">
<h3>Uptime (24h)</h3>
<div id="uptime" class="value">-- %</div>
</div>
<div class="card">
<h3>Latency</h3>
<div id="latency" class="value">-- ms</div>
</div>
<div class="card">
<h3>DNS Lookup</h3>
<div id="dns" class="value">-- ms</div>
</div>
<div class="card">
<h3>Search Response</h3>
<div id="search" class="value">-- ms</div>
</div>
<div class="card">
<h3>SSL Expiry</h3>
<div id="ssl" class="value" style="font-size:22px;">--</div>
</div>
<div class="card">
<h3>Days Remaining</h3>
<div id="days" class="value">--</div>
</div>
</div>
<canvas id="latencyChart" height="100"></canvas>
<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="history">
</tbody>
</table>
<script>
async function loadData(){
const response=await fetch("metrics.json");
const data=await response.json();
document.getElementById("uptime").innerHTML=data.uptime+" %";
document.getElementById("latency").innerHTML=data.last_check.latency+" ms";
document.getElementById("dns").innerHTML=data.last_check.dns+" ms";
document.getElementById("search").innerHTML=data.last_check.search_latency+" ms";
document.getElementById("ssl").innerHTML=data.last_check.ssl_expiry;
document.getElementById("days").innerHTML=data.last_check.ssl_days_left+" days";
let tbody=document.getElementById("history");
tbody.innerHTML="";
data.history.reverse().forEach(item=>{
tbody.innerHTML+=`
<tr>
<td>${item.time}</td>
<td class="${item.status==200?'good':'bad'}">
${item.status}
</td>
<td>${item.latency} ms</td>
<td>${item.dns} ms</td>
<td>${item.search_latency} ms</td>
<td>${item.ssl_days_left}</td>
</tr>
`;
});
const labels=[];
for(let i=1;i<=data.latency_chart.length;i++){
labels.push(i);
}
new Chart(document.getElementById("latencyChart"),{
type:"line",
data:{
labels:labels,
datasets:[{
label:"Latency (ms)",
data:data.latency_chart,
fill:false,
borderWidth:2
}]
},
options:{
responsive:true,
plugins:{
legend:{
display:true
}
}
}
});
}
loadData();
setInterval(loadData,60000);
</script>
</body>
</html>