31 lines
864 B
Bash
31 lines
864 B
Bash
#!/bin/bash
|
|
# Health check script for cron/scheduler
|
|
|
|
# Check if containers are running
|
|
if ! docker ps | grep -q "btc_timescale"; then
|
|
echo "ERROR: TimescaleDB container not running"
|
|
# Send notification (if configured)
|
|
exit 1
|
|
fi
|
|
|
|
if ! docker ps | grep -q "btc_collector"; then
|
|
echo "ERROR: Data collector container not running"
|
|
exit 1
|
|
fi
|
|
|
|
# Check database connectivity
|
|
docker exec btc_timescale pg_isready -U btc_bot -d btc_data > /dev/null 2>&1
|
|
if [ $? -ne 0 ]; then
|
|
echo "ERROR: Cannot connect to database"
|
|
exit 1
|
|
fi
|
|
|
|
# Check if recent data exists
|
|
LATEST=$(docker exec btc_timescale psql -U btc_bot -d btc_data -t -c "SELECT MAX(time) FROM candles WHERE time > NOW() - INTERVAL '5 minutes';" 2>/dev/null)
|
|
if [ -z "$LATEST" ]; then
|
|
echo "WARNING: No recent data in database"
|
|
exit 1
|
|
fi
|
|
|
|
echo "OK: All systems operational"
|
|
exit 0 |