Final Submission: Live app URL integrated in health monitor
هذا الالتزام موجود في:
@@ -1,24 +1,19 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# استبدل هذا الرابط بالرابط العام المستلم من غيمة
|
TARGET_URL="https://q1-app-aad7f93598bc.hosted.ghaymah.systems/health"
|
||||||
TARGET_URL="https://q1-app.deploy.ghaymah.systems/health"
|
|
||||||
|
|
||||||
echo "Starting Monitoring for $TARGET_URL..."
|
echo "Starting Monitoring for $TARGET_URL..."
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
||||||
|
|
||||||
# جلب الاستجابة وحساب الوقت
|
|
||||||
RESPONSE=$(curl -s "$TARGET_URL")
|
RESPONSE=$(curl -s "$TARGET_URL")
|
||||||
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" "$TARGET_URL")
|
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" "$TARGET_URL")
|
||||||
RESPONSE_TIME=$(curl -s -w "%{time_total}" -o /dev/null "$TARGET_URL")
|
RESPONSE_TIME=$(curl -s -w "%{time_total}" -o /dev/null "$TARGET_URL")
|
||||||
|
|
||||||
# استخراج عدد الطلبات من الـ Endpoint
|
|
||||||
TOTAL_REQUESTS=$(echo "$RESPONSE" | grep -o '"total_requests":[0-9]*' | grep -o '[0-9]*')
|
TOTAL_REQUESTS=$(echo "$RESPONSE" | grep -o '"total_requests":[0-9]*' | grep -o '[0-9]*')
|
||||||
|
|
||||||
echo "[$TIMESTAMP] Status: $HTTP_STATUS | Latency: ${RESPONSE_TIME}s | Requests: ${TOTAL_REQUESTS:-0}"
|
echo "[$TIMESTAMP] Status: $HTTP_STATUS | Latency: ${RESPONSE_TIME}s | Requests: ${TOTAL_REQUESTS:-0}"
|
||||||
|
|
||||||
# تحديث ملف المتركس للداشبورد
|
|
||||||
echo "{\"timestamp\": \"$TIMESTAMP\", \"status\": \"$HTTP_STATUS\", \"latency\": $RESPONSE_TIME, \"total_requests\": ${TOTAL_REQUESTS:-0}}" > metrics.json
|
echo "{\"timestamp\": \"$TIMESTAMP\", \"status\": \"$HTTP_STATUS\", \"latency\": $RESPONSE_TIME, \"total_requests\": ${TOTAL_REQUESTS:-0}}" > metrics.json
|
||||||
|
|
||||||
sleep 30
|
sleep 30
|
||||||
|
|||||||
المرجع في مشكلة جديدة
حظر مستخدم