refactor: removed redundant variable naming.

This commit is contained in:
Leonard Excoffier
2024-09-07 17:17:15 -04:00
parent a128ccdf40
commit 712b794830

View File

@@ -1,26 +1,19 @@
#!/bin/bash #!/bin/bash
# List of websites to monitor
websites=$WEBSITES
# Discord Webhook URL
webhook_url=$WEBHOOK_URL
# Function to send a message to Discord webhook # Function to send a message to Discord webhook
send_discord_notification() { send_discord_notification() {
local message=$1 local message=$1
curl -H "Content-Type: application/json" \ curl -H "Content-Type: application/json" \
-X POST \ -X POST \
-d "{\"content\": \"$message\"}" \ -d "{\"content\": \"$message\"}" \
"$webhook_url" "$WEBHOOK_URL"
} }
# Loop through the websites and check their status # Loop through the websites and check their status
for website in "${websites[@]}"; do for website in "${$WEBSITES[@]}"; do
response=$(curl -s -o /dev/null -L -w "%{http_code}" --max-time 10 --connect-timeout 5 --insecure "$website") response=$(curl -s -o /dev/null -L -w "%{http_code}" --max-time 10 --connect-timeout 5 --insecure "$website")
if [ "$response" != "200" ]; then if [ "$response" != "200" ]; then
send_discord_notification "$DISCORD_ID Alert: Website $website is down (HTTP $response)" send_discord_notification "$DISCORD_ID Alert: Website $website is down (HTTP $response)"
fi fi
done done