Files
wevads-platform/backend-health-check.sh
2026-02-26 04:53:11 +01:00

107 lines
3.3 KiB
Bash
Executable File

#!/bin/bash
# Script de vérification backend uniquement - PAS DE FRONTEND
echo "=== VÉRIFICATION BACKEND WEVADS ARSENAL ==="
echo "Date: $(date)"
echo ""
# 1. Services backend
echo "1. 🔧 SERVICES BACKEND:"
services=("postgresql" "redis-server" "apache2")
for service in "${services[@]}"; do
if systemctl is-active --quiet "$service" 2>/dev/null; then
echo "$service"
else
echo "$service"
fi
done
# 2. Ports backend
echo ""
echo "2. 🔌 PORTS BACKEND:"
backend_ports=(
"5432:PostgreSQL"
"6379:Redis"
"5821:Apache/API"
)
for port_info in "${backend_ports[@]}"; do
port="${port_info%:*}"
service="${port_info#*:}"
if timeout 1 bash -c "echo >/dev/tcp/127.0.0.1/$port" 2>/dev/null; then
echo "$port ($service)"
else
echo "$port ($service)"
fi
done
# 3. APIs backend
echo ""
echo "3. 🌐 APIS BACKEND:"
backend_apis=(
"http://localhost:5821/api/monitor.php?action=health"
"http://localhost:5821/api/hamid-api.php?action=status"
"http://localhost:5821/deliverads/send-engine.php?action=test"
"http://localhost:5821/deliverads/brain-unified-send.php?action=test"
)
for api in "${backend_apis[@]}"; do
name=$(basename "${api%%\?*}")
if timeout 3 curl -s -f "$api" >/dev/null 2>&1; then
echo "$name"
else
echo "$name"
fi
done
# 4. Base de données
echo ""
echo "4. 🗄️ BASE DE DONNÉES:"
if PGPASSWORD=admin123 psql -U admin -d adx_system -c "SELECT 1" >/dev/null 2>&1; then
echo " ✅ PostgreSQL connecté"
# Compter les configs
count=$(PGPASSWORD=admin123 psql -U admin -d adx_system -t -c "SET search_path TO admin; SELECT COUNT(*) FROM brain_send_configs WHERE is_winner" 2>/dev/null)
echo " 📊 Configs gagnantes: ${count:-0}"
else
echo " ❌ PostgreSQL non connecté"
fi
# 5. Fichiers backend critiques
echo ""
echo "5. 📁 FICHIERS BACKEND CRITIQUES:"
backend_files=(
"/opt/wevads/public/api/monitor.php"
"/opt/wevads/public/api/hamid-api.php"
"/opt/wevads/public/deliverads/brain-unified-send.php"
"/opt/wevads/public/deliverads/send-engine.php"
)
for file in "${backend_files[@]}"; do
if [ -f "$file" ]; then
if php -l "$file" >/dev/null 2>&1; then
echo "$(basename $file)"
else
echo "$(basename $file) - Erreur syntaxe"
fi
else
echo "$(basename $file) - Manquant"
fi
done
# 6. Résumé
echo ""
echo "=== 📊 RÉSUMÉ BACKEND ==="
echo "Services: $(systemctl is-active postgresql redis-server apache2 2>/dev/null | grep -c 'active' | xargs echo)/3"
echo "APIs: $(for api in "${backend_apis[@]}"; do timeout 2 curl -s -f "$api" >/dev/null && echo 1; done | wc -l | xargs echo)/4"
echo "DB: $(PGPASSWORD=admin123 psql -U admin -d adx_system -c 'SELECT 1' >/dev/null 2>&1 && echo '✅' || echo '❌')"
echo "Fichiers: $(for file in "${backend_files[@]}"; do [ -f "$file" ] && php -l "$file" >/dev/null && echo 1; done | wc -l | xargs echo)/4"
echo ""
echo "=== ✅ BACKEND STATUS ==="
if [ $(systemctl is-active postgresql redis-server apache2 2>/dev/null | grep -c 'active') -eq 3 ] && \
[ $(for api in "${backend_apis[@]}"; do timeout 2 curl -s -f "$api" >/dev/null && echo 1; done | wc -l) -eq 4 ]; then
echo "✅ BACKEND OPÉRATIONNEL"
else
echo "⚠️ BACKEND AVEC PROBLÈMES"
fi