Running a VPS without resource monitoring is like driving without a dashboard — you won’t know your CPU is maxed out, RAM exhausted, or disk filling until something breaks. This tutorial covers how to set up comprehensive monitoring on your Linux VPS using both lightweight CLI tools and modern observability stacks. If you’re looking for a VPS with enough headroom for monitoring agents, check the VPS provider comparison.
1. Quick-Start: Built-in CLI Tools
Every Linux VPS ships with basic monitoring tools. These are zero-overhead and work even on the smallest plans.
CPU Monitoring
# Real-time CPU per core
mpstat -P ALL 2
# CPU steal check (high steal = overprovisioned host)
mpstat 1 5 | awk '/Average/ {print "CPU steal: " $NF "%"}'
# Top CPU consumers
top -bn1 | head -20
Memory Monitoring
# Memory usage summary
free -h
# Detailed memory breakdown
cat /proc/meminfo | grep -E "^(MemTotal|MemFree|MemAvailable|Buffers|Cached|SwapTotal|SwapFree)"
# OOM score of running processes (high scores get killed first)
for pid in /proc/[0-9]*/; do echo "$(cat $pid/oom_score 2>/dev/null) $(cat $pid/comm 2>/dev/null)"; done | sort -rn | head -10
Disk Monitoring
# Disk usage by partition
df -h
# I/O stats with latency
iostat -x 1 5
# Find largest directories
sudo du -sh /* 2>/dev/null | sort -rh | head -15
Network Monitoring
# Bandwidth usage per interface
vnstat -i eth0 -m
# Real-time connections
ss -s
# Listening ports and processes
ss -tlnp
2. Modern Observability Stack: Netdata
Netdata is the gold standard for VPS monitoring — real-time, low-overhead (~1% CPU, 100 MB RAM), and zero configuration. It monitors 2000+ metrics out of the box.
# Install Netdata (one-liner)
bash <(curl -Ss https://my-netdata.io/kickstart.sh)
# Access dashboard
# http://YOUR_VPS_IP:19999
# Start on boot
sudo systemctl enable netdata --now
Netdata Alarm Configuration
Netdata ships with sensible defaults, but you should customize alarms for your workload:
# Edit health alarms
sudo nano /etc/netdata/health.d/cpu.conf
# Example: raise CPU alarm threshold
cpu_user_threshold: 90
cpu_iowait_threshold: 30
# Reload configuration
sudo netdatacli reload-health
3. Prometheus + Grafana Stack (Heavier but More Powerful)
For multi-server setups or long-term trend analysis, Prometheus + Grafana is the industry standard. Expect ~200–400 MB RAM overhead.
Installing Node Exporter
# Download and run node_exporter
wget https://github.com/prometheus/node_exporter/releases/latest/download/node_exporter-*.linux-amd64.tar.gz
tar xvf node_exporter-*.tar.gz
sudo cp node_exporter-*/node_exporter /usr/local/bin/
sudo useradd -rs /bin/false node_exporter
sudo tee /etc/systemd/system/node_exporter.service <
Installing Prometheus
# Quick Docker setup (recommended for VPS)
sudo docker run -d --name prometheus \
-p 9090:9090 \
-v /etc/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml \
prom/prometheus
Installing Grafana
sudo docker run -d --name grafana \
-p 3000:3000 \
-e "GF_SECURITY_ADMIN_PASSWORD=strongpassword" \
grafana/grafana
4. Setting Up Alerts and Notifications
Monitoring without alerts is just logging. Set up notifications to your team chat or email.
Netdata Cloud Notifications
# Netdata supports Slack, Discord, Telegram, PagerDuty, email
# Configure in /etc/netdata/health_alarm_notify.conf
# Example: Telegram
SEND_TELEGRAM="YES"
DEFAULT_RECIPIENT_TELEGRAM="-1001234567890"
TELEGRAM_BOT_TOKEN="123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11"
Prometheus Alertmanager
# Example alert rule for high CPU
sudo tee /etc/prometheus/rules/cpu_alerts.yml < 85
for: 5m
labels:
severity: warning
annotations:
summary: "CPU usage > 85% on {{ $labels.instance }}"
EOF
Conclusion
Start with built-in CLI tools for quick checks, add Netdata for real-time dashboarding, graduate to Prometheus + Grafana for long-term trending and multi-host visibility. The right monitoring stack for your VPS depends on your budget for RAM overhead and your need for historical data. For small single-server setups, Netdata alone is the most cost-effective choice.




Leave a Reply
You must be logged in to post a comment.