add files
هذا الالتزام موجود في:
13
q1-deploy-monitor/Dockerfile
Normal file
13
q1-deploy-monitor/Dockerfile
Normal file
@@ -0,0 +1,13 @@
|
||||
FROM python:3.12-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY requirements.txt .
|
||||
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY app.py .
|
||||
|
||||
EXPOSE 5000
|
||||
|
||||
CMD ["python", "app.py"]
|
||||
92
q1-deploy-monitor/dashboard.html
Normal file
92
q1-deploy-monitor/dashboard.html
Normal file
@@ -0,0 +1,92 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Ghaymah SRE Dashboard</title>
|
||||
|
||||
<style>
|
||||
body{
|
||||
font-family:Arial,sans-serif;
|
||||
background:#f4f4f4;
|
||||
margin:40px;
|
||||
}
|
||||
|
||||
.container{
|
||||
max-width:700px;
|
||||
margin:auto;
|
||||
background:white;
|
||||
padding:20px;
|
||||
border-radius:10px;
|
||||
box-shadow:0 0 10px rgba(0,0,0,.1);
|
||||
}
|
||||
|
||||
.card{
|
||||
margin:15px 0;
|
||||
padding:15px;
|
||||
border-radius:8px;
|
||||
background:#fafafa;
|
||||
}
|
||||
|
||||
.value{
|
||||
font-size:28px;
|
||||
font-weight:bold;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<h2>Ghaymah API Monitoring Dashboard</h2>
|
||||
|
||||
<div class="card">
|
||||
<h3>Status</h3>
|
||||
<div id="status" class="value">Checking...</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h3>Latency</h3>
|
||||
<div id="latency" class="value">-- ms</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h3>Total Requests</h3>
|
||||
<div id="requests" class="value">0</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
async function update(){
|
||||
|
||||
const start=performance.now();
|
||||
|
||||
try{
|
||||
|
||||
const response=await fetch("http://localhost:5000/health");
|
||||
const data=await response.json();
|
||||
|
||||
const latency=(performance.now()-start).toFixed(2);
|
||||
|
||||
document.getElementById("status").innerHTML="🟢 UP";
|
||||
document.getElementById("latency").innerHTML=latency+" ms";
|
||||
document.getElementById("requests").innerHTML=data.requests;
|
||||
|
||||
}catch(e){
|
||||
|
||||
document.getElementById("status").innerHTML="🔴 DOWN";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
update();
|
||||
|
||||
setInterval(update,30000);
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
22
q1-deploy-monitor/health-check.sh
Executable file
22
q1-deploy-monitor/health-check.sh
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
URL="http://localhost:5000/health"
|
||||
|
||||
while true
|
||||
do
|
||||
START=$(date +%s%3N)
|
||||
|
||||
STATUS=$(curl -s -o /dev/null -w "%{http_code}" "$URL")
|
||||
|
||||
END=$(date +%s%3N)
|
||||
|
||||
LATENCY=$((END-START))
|
||||
|
||||
if [ "$STATUS" -eq 200 ]; then
|
||||
echo "$(date) | UP | ${LATENCY}ms"
|
||||
else
|
||||
echo "$(date) | DOWN"
|
||||
fi
|
||||
|
||||
sleep 30
|
||||
done
|
||||
المرجع في مشكلة جديدة
حظر مستخدم