Resource Monitoring
How to check CPU, RAM, disk and network on your server in real time
Monitoring your server's resources is essential to understand if the system is running correctly or approaching its limits.
CPU and RAM in real time
top: basic monitor (already installed)
topUseful keys inside top:
P: sort by CPUM: sort by RAMk: kill a process (enter the PID)q: exit
htop: advanced monitor (recommended)
# Installation
apt install htop # Debian/Ubuntu
dnf install htop # CentOS/AlmaLinux
# Launch
htophtop shows graphical bars for each CPU core and RAM, and is much more readable than top.
Current RAM usage
free -hExample output:
total used free shared buff/cache available
Mem: 3.8G 1.2G 800M 45M 1.8G 2.4G
RAM: 4.0G 0B 4.0GThe available column is the one that matters: it's the RAM actually available for new processes.
Current disk usage
df -hTo see only the main partition:
df -h /Processes consuming the most resources
Top 10 processes using the most CPU:
ps aux --sort=-%cpu | head -11Top 10 processes using the most RAM:
ps aux --sort=-%mem | head -11Real-time network traffic
# Install nethogs to see traffic by process
apt install nethogs
nethogs
# Or iftop to see traffic by connection
apt install iftop
iftopDisk I/O statistics
# Show disk I/O in real time
iostat -x 1
# To install (if not present)
apt install sysstatSystem load (load average)
uptimeExample output:
14:32:01 up 5 days, 3:21, 1 user, load average: 0.12, 0.08, 0.05The three values are the load average for the last 1, 5 and 15 minutes. A value equal to the number of CPU cores indicates 100% utilization. Higher values indicate that there are processes waiting.
To find out how many cores you have:
nproc