20 أسطر
530 B
Bash
20 أسطر
530 B
Bash
#!/bin/bash
|
|
|
|
URL="http://localhost:8000/health"
|
|
|
|
echo "Starting application monitoring. Checking every 30 seconds..."
|
|
|
|
while true; do
|
|
# Send HTTP GET request and get the status code
|
|
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" $URL)
|
|
TIMESTAMP=$(date '+%Y-%m-%d %H:%M:%S')
|
|
|
|
if [ "$RESPONSE" -eq 200 ]; then
|
|
echo "[$TIMESTAMP] Status: HEALTHY (HTTP 200)"
|
|
else
|
|
echo "[$TIMESTAMP] Status: DOWN (HTTP $RESPONSE)"
|
|
fi
|
|
|
|
# Wait for 30 seconds before the next check
|
|
sleep 30
|
|
done |