Server Management

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)

top

Useful keys inside top:

  • P: sort by CPU
  • M: sort by RAM
  • k: kill a process (enter the PID)
  • q: exit
# Installation
apt install htop   # Debian/Ubuntu
dnf install htop   # CentOS/AlmaLinux

# Launch
htop

htop shows graphical bars for each CPU core and RAM, and is much more readable than top.


Current RAM usage

free -h

Example output:

              total        used        free      shared  buff/cache   available
Mem:           3.8G        1.2G        800M        45M        1.8G        2.4G
RAM:           4.0G          0B        4.0G

The available column is the one that matters: it's the RAM actually available for new processes.


Current disk usage

df -h

To see only the main partition:

df -h /

Processes consuming the most resources

Top 10 processes using the most CPU:

ps aux --sort=-%cpu | head -11

Top 10 processes using the most RAM:

ps aux --sort=-%mem | head -11

Real-time network traffic

# Install nethogs to see traffic by process
apt install nethogs
nethogs

# Or iftop to see traffic by connection
apt install iftop
iftop

Disk I/O statistics

# Show disk I/O in real time
iostat -x 1

# To install (if not present)
apt install sysstat

System load (load average)

uptime

Example output:

14:32:01 up 5 days,  3:21,  1 user,  load average: 0.12, 0.08, 0.05

The 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

On this page