MonitoringCPURAM5 min read

Monitor CPU, RAM and disk

Monitor CPU, RAM, disk, and network usage on your VPS to detect performance issues early.


Monitoring your VPS resources helps you identify bottlenecks, plan upgrades and detect anomalies before they cause downtime.

Quick overview with htop

Install and run htop for an interactive process viewer:

bash
sudo apt install htop -y
htop

htop shows CPU usage per core, memory usage, swap, load average and running processes. Press q to exit.

Memory usage

bash
free -h

Shows total, used, free, shared, buffer/cache and available memory.

Disk usage

bash
# Overall disk usage
df -h

# Directory sizes
du -sh /var/log
du -sh /home/*

# Find largest files
sudo find / -type f -size +100M -exec ls -lh {} \;

CPU information

bash
# Number of cores
nproc

# Detailed CPU info
lscpu

# Current load average
uptime

I/O monitoring with iotop

bash
sudo apt install iotop -y
sudo iotop

Shows which processes are reading/writing to disk.

Network monitoring

bash
# Bandwidth per interface
sudo apt install iftop -y
sudo iftop

# Connection statistics
ss -tuln

Continuous monitoring with vmstat

bash
vmstat 5  # Update every 5 seconds

Set up alerts (optional)

Create a simple script to alert on high usage:

bash
#!/bin/bash
CPU=$(top -bn1 | grep 'Cpu(s)' | awk '{print $2}')
MEM=$(free | grep Mem | awk '{printf "%.0f", $3/$2 * 100}')
DISK=$(df / | tail -1 | awk '{print $5}' | tr -d '%')

echo "CPU: ${CPU}% | RAM: ${MEM}% | Disk: ${DISK}%"

Tip

For production VPS on Baires Host, consider setting up Prometheus + Grafana or Netdata for continuous monitoring with dashboards and alerting.


Was this guide helpful?