104 lines
2.8 KiB
Bash
Executable File
104 lines
2.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# Service Health Check Script
|
|
# Checks status of all critical services
|
|
|
|
set -e
|
|
|
|
echo "=== tower-of-joy Health Check ==="
|
|
echo "$(date)"
|
|
echo ""
|
|
|
|
# Define service check function
|
|
check_service() {
|
|
local name=$1
|
|
local port=$2
|
|
local container=$3
|
|
|
|
# Check container running
|
|
if docker ps --format '{{.Names}}' | grep -q "^${container}$"; then
|
|
# Check port responding
|
|
if curl -f -s -o /dev/null -w "%{http_code}" "http://localhost:${port}" > /dev/null 2>&1 || \
|
|
curl -f -s -o /dev/null "http://localhost:${port}" > /dev/null 2>&1; then
|
|
echo "✅ ${name} (port ${port})"
|
|
else
|
|
echo "⚠️ ${name} - container running but port ${port} not responding"
|
|
fi
|
|
else
|
|
echo "❌ ${name} - container not running"
|
|
fi
|
|
}
|
|
|
|
# Check infrastructure services
|
|
echo "[Infrastructure Services]"
|
|
check_service "Portainer" "8080" "portainer"
|
|
check_service "Nginx Proxy Manager" "8000" "nginx-proxy-manager"
|
|
check_service "Ollama" "11434" "ollama"
|
|
echo ""
|
|
|
|
# Check networking
|
|
echo "[Networking]"
|
|
check_service "Headscale" "8085" "headscale"
|
|
if command -v tailscale &> /dev/null; then
|
|
if tailscale status &> /dev/null; then
|
|
echo "✅ Tailscale connected"
|
|
else
|
|
echo "⚠️ Tailscale installed but not connected"
|
|
fi
|
|
else
|
|
echo "⚠️ Tailscale not installed"
|
|
fi
|
|
echo ""
|
|
|
|
# Check monitoring
|
|
echo "[Monitoring]"
|
|
check_service "Uptime Kuma" "3001" "uptime-kuma"
|
|
check_service "Netdata" "19999" "netdata"
|
|
check_service "Heimdall" "8888" "heimdall"
|
|
echo ""
|
|
|
|
# Check application services (if deployed)
|
|
echo "[Applications]"
|
|
check_service "Jellyfin" "8096" "jellyfin"
|
|
check_service "Nextcloud" "8082" "nextcloud"
|
|
check_service "Samba" "445" "samba"
|
|
echo ""
|
|
|
|
# Check storage
|
|
echo "[Storage]"
|
|
ssd_usage=$(df -h /home/jpmschweitzer/docker-data 2>/dev/null | awk 'NR==2 {print $5}' | sed 's/%//')
|
|
hdd_usage=$(df -h /mnt/media 2>/dev/null | awk 'NR==2 {print $5}' | sed 's/%//')
|
|
|
|
if [ -n "$ssd_usage" ]; then
|
|
if [ "$ssd_usage" -lt 80 ]; then
|
|
echo "✅ SSD: ${ssd_usage}% used"
|
|
elif [ "$ssd_usage" -lt 90 ]; then
|
|
echo "⚠️ SSD: ${ssd_usage}% used (getting full)"
|
|
else
|
|
echo "❌ SSD: ${ssd_usage}% used (critically full!)"
|
|
fi
|
|
else
|
|
echo "⚠️ SSD: Unable to check"
|
|
fi
|
|
|
|
if [ -n "$hdd_usage" ]; then
|
|
if [ "$hdd_usage" -lt 80 ]; then
|
|
echo "✅ HDD: ${hdd_usage}% used"
|
|
elif [ "$hdd_usage" -lt 90 ]; then
|
|
echo "⚠️ HDD: ${hdd_usage}% used (getting full)"
|
|
else
|
|
echo "❌ HDD: ${hdd_usage}% used (critically full!)"
|
|
fi
|
|
else
|
|
echo "❌ HDD: Not mounted at /mnt/media"
|
|
fi
|
|
echo ""
|
|
|
|
# Check Docker
|
|
echo "[Docker Status]"
|
|
running=$(docker ps -q | wc -l)
|
|
total=$(docker ps -aq | wc -l)
|
|
echo "Containers: ${running} running / ${total} total"
|
|
echo ""
|
|
|
|
echo "=== Health Check Complete ==="
|