#!/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
