#!/bin/bash TARGET_URL="https://q1-app-aad7f93598bc.hosted.ghaymah.systems/health" echo "Starting Monitoring for $TARGET_URL..." while true; do TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ") RESPONSE=$(curl -s "$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") 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\": \"$TIMESTAMP\", \"status\": \"$HTTP_STATUS\", \"latency\": $RESPONSE_TIME, \"total_requests\": ${TOTAL_REQUESTS:-0}}" > metrics.json sleep 30 done