← Retour
#\!/bin/bash
# Healthcheck externe depuis O2switch
# Cron: */5 * * * *
LOG="/home/deas8499/logs/healthcheck.log"
ALERT_URL="https://ntfy.33800.nowhere84.com/infra-alerts"
# Services à vérifier (via reverse proxy)
SERVICES=(
"https://dashboard.33800.nowhere84.com|Dashboard"
"https://grafana.33800.nowhere84.com|Grafana"
"https://gitlab.33800.nowhere84.com|GitLab"
"https://ntfy.33800.nowhere84.com|Ntfy"
)
for svc in "${SERVICES[@]}"; do
url="${svc%%|*}"
name="${svc##*|}"
status=$(curl -s -o /dev/null -w "%{http_code}" --max-time 15 -k -L "$url" 2>/dev/null)
# 403 = OK (restriction IP), on check juste si répond
if [ "$status" = "000" ]; then
echo "$(date +%Y-%m-%d %H:%M:%S) DOWN $name ($url) - No response" >> $LOG
curl -s -k -d "🔴 Service DOWN: $name - No response from O2switch" "$ALERT_URL" > /dev/null 2>&1
fi
done