Skip to content

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:

Troubleshooting Common Issues

High CPU Usage

  1. Check container stats: docker stats
  2. Identify problematic container
  3. Restart if necessary: docker restart [container]

Memory Leaks

  1. Monitor memory over time: free -m -s 5
  2. Check for growing processes: ps aux | sort -nrk 4 | head
  3. Restart services if needed

Network Issues

  1. Check connectivity: ping -c 4 8.8.8.8
  2. Verify DNS: nslookup exit.idlegaming.org
  3. Check firewall: ufw status

Best Practices

  1. Regular Reviews: Check logs daily
  2. Automate Alerts: Set up automated monitoring
  3. Document Issues: Keep a log of problems and solutions
  4. Capacity Planning: Monitor trends for growth
  5. Security Monitoring: Watch for unusual activity

Monitoring Tools

Consider implementing additional monitoring tools like Prometheus, Grafana, or Netdata for more comprehensive monitoring capabilities.