Monitoring¶
This guide covers monitoring the VPN Exit Controller system for health, performance, and security.
Overview¶
Effective monitoring is crucial for maintaining a reliable VPN exit node service. This guide covers the tools and procedures for monitoring all aspects of the system.
System Monitoring¶
Service Health¶
Monitor core services:
# Check VPN controller service
systemctl status vpn-controller
# Check documentation webhook
systemctl status docs-webhook
# Check Docker services
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.RunningFor}}"
Container Health¶
Monitor VPN exit node containers:
# Check all VPN containers
docker ps | grep vpn-exit
# Check specific country node
docker inspect vpn-exit-us --format='{{.State.Health.Status}}'
# View container resource usage
docker stats --no-stream
Performance Monitoring¶
API Performance¶
# Check API response time
time curl -s https://exit.idlegaming.org/api/health
# Monitor API logs
journalctl -u vpn-controller -f | grep -E "(ERROR|WARNING|response_time)"
Proxy Performance¶
# Test proxy response time
time curl -x http://admin:[email protected]:3128 http://httpbin.org/ip
# Check HAProxy statistics
docker exec haproxy-default echo "show stat" | socat stdio /var/run/haproxy/admin.sock
Log Monitoring¶
Key Log Locations¶
- API Logs:
journalctl -u vpn-controller -f - Webhook Logs:
/opt/vpn-exit-controller/logs/webhook.log - Docker Logs:
docker logs [container-name] - Rebuild Logs:
/opt/vpn-exit-controller/logs/docs-rebuild.log
Log Analysis¶
# Check for errors in last hour
journalctl -u vpn-controller --since "1 hour ago" | grep ERROR
# Monitor real-time errors
tail -f /var/log/syslog | grep -E "(error|fail|critical)"
# Check container restart frequency
docker ps -a --filter "name=vpn-" --format "table {{.Names}}\t{{.Status}}"
Metrics Collection¶
System Metrics¶
# CPU and Memory usage
top -b -n 1 | head -20
# Disk usage
df -h | grep -E "(/$|/opt|/var)"
# Network connections
ss -tunap | grep -E "(8080|3128|1080)"
Container Metrics¶
# Container resource usage
docker stats --no-stream --format "table {{.Container}}\t{{.CPUPerc}}\t{{.MemUsage}}"
# Container network stats
docker exec vpn-exit-us cat /proc/net/dev
Alerting¶
Basic Health Checks¶
Create a simple monitoring script:
#!/bin/bash
# /opt/vpn-exit-controller/scripts/health-check.sh
# Check API
if ! curl -sf https://exit.idlegaming.org/api/health > /dev/null; then
echo "ALERT: API is down"
fi
# Check containers
if [ $(docker ps | grep -c vpn-exit) -lt 10 ]; then
echo "ALERT: Some VPN containers are down"
fi
# Check disk space
if [ $(df -h / | awk 'NR==2 {print $5}' | sed 's/%//') -gt 80 ]; then
echo "ALERT: Disk usage above 80%"
fi
Automated Monitoring¶
Set up a cron job for regular checks:
# Add to crontab
*/5 * * * * /opt/vpn-exit-controller/scripts/health-check.sh >> /opt/vpn-exit-controller/logs/health-check.log 2>&1
Dashboard Monitoring¶
Access monitoring dashboards:
- VPN Dashboard: https://exit.idlegaming.org/
- API Metrics: https://exit.idlegaming.org/api/metrics/summary
- Node Status: https://exit.idlegaming.org/api/nodes
Troubleshooting Common Issues¶
High CPU Usage¶
- Check container stats:
docker stats - Identify problematic container
- Restart if necessary:
docker restart [container]
Memory Leaks¶
- Monitor memory over time:
free -m -s 5 - Check for growing processes:
ps aux | sort -nrk 4 | head - Restart services if needed
Network Issues¶
- Check connectivity:
ping -c 4 8.8.8.8 - Verify DNS:
nslookup exit.idlegaming.org - Check firewall:
ufw status
Best Practices¶
- Regular Reviews: Check logs daily
- Automate Alerts: Set up automated monitoring
- Document Issues: Keep a log of problems and solutions
- Capacity Planning: Monitor trends for growth
- Security Monitoring: Watch for unusual activity
Monitoring Tools
Consider implementing additional monitoring tools like Prometheus, Grafana, or Netdata for more comprehensive monitoring capabilities.