#!/bin/bash URL="http://localhost:5000" REQUESTS=0 while true do REQUESTS=$((REQUESTS+1)) RESPONSE=$(curl -o /dev/null -s -w "%{http_code} %{time_total}" "$URL/health") STATUS_CODE=$(echo "$RESPONSE" | cut -d' ' -f1) RESPONSE_TIME=$(echo "$RESPONSE" | cut -d' ' -f2) if [ "$STATUS_CODE" = "200" ] then STATUS="UP" else STATUS="DOWN" fi TIMESTAMP=$(date -Iseconds) LATENCY_MS=$(awk "BEGIN {print $RESPONSE_TIME * 1000}") python update_monitor.py \ "$TIMESTAMP" \ "$(echo $STATUS | tr '[:upper:]' '[:lower:]')" \ "$LATENCY_MS" \ "$REQUESTS" echo "Status : $STATUS" echo "Latency : ${LATENCY_MS} ms" echo "Requests : $REQUESTS" echo "-------------------------" sleep 30 done