Files
downdetector/isalive.sh
2024-09-07 17:53:34 -04:00

23 lines
707 B
Bash

#!/bin/bash
# Function to send a message to Discord webhook
send_discord_notification() {
local message=$1
curl -H "Content-Type: application/json" \
-X POST \
-d "{\"content\": \"$message\"}" \
"$WEBHOOK_URL"
}
# Split the comma-separated string of websites into a proper list
IFS=',' read -ra website_array <<< "$WEBSITES"
# Loop through the websites and check their status
for website in "${website_array[@]}"; do
response=$(curl -s -o /dev/null -L -w "%{http_code}" --max-time 10 --connect-timeout 5 --insecure "$website")
if [ "$response" != "200" ]; then
send_discord_notification "$DISCORD_ID Alert: Website $website is down (HTTP $response)"
fi
done