Skip to main content
Back to Category

Linux VDS Server Monitoring: CPU, RAM, Disk and Network

Complete guide to monitoring Linux VDS server resources: htop, free, df, iostat commands, network monitoring tools, and automated alert scripts.

Read time: 9 min Server Management
monitoringcpuramdiskhtopperformanceresources

Table of Contents

Introduction

Monitoring your server's resource usage is essential for maintaining optimal performance and identifying potential issues before they become critical. This guide covers the most important commands and tools for monitoring CPU, RAM, disk, and network usage on Linux servers.

CPU Monitoring

top Command

The top command provides a real-time view of system processes:

hljs bash
top

Key metrics to watch:

  • %us: User space CPU usage
  • %sy: System (kernel) CPU usage
  • %id: Idle CPU percentage
  • load average: System load (1, 5, 15 minute averages)

Load average should ideally be below the number of CPU cores. For a 4-core server, a load average above 4.0 indicates the system is overloaded.

htop Command

htop is an enhanced version of top with a more user-friendly interface:

hljs bash
# Install htop
sudo apt install htop -y    # Debian/Ubuntu
sudo yum install htop -y    # CentOS/RHEL

# Run htop
htop

htop features:

  • Color-coded CPU and memory bars
  • Process tree view (F5)
  • Easy process killing (F9)
  • Search processes (F3)
  • Sort by any column (F6)

CPU Information

hljs bash
# Number of CPU cores
nproc

# Detailed CPU info
lscpu

# Per-core usage
mpstat -P ALL 1 5

RAM Monitoring

free Command

hljs bash
free -h

Example output:

              total        used        free      shared  buff/cache   available
Mem:          7.8Gi       3.2Gi       1.1Gi       0.2Gi       3.5Gi       4.1Gi
Swap:         2.0Gi          0B       2.0Gi
ColumnDescription
totalTotal physical RAM
usedRAM in use
freeCompletely unused RAM
buff/cacheRAM used for buffers and cache (reclaimable)
availableRAM available for new applications

The "available" column is more important than "free". Linux uses free RAM for disk caching, which is automatically released when applications need it.

Swap Usage

hljs bash
# Check swap usage
swapon --show
free -h | grep Swap

# Find processes using swap
for file in /proc/*/status; do
  awk '/VmSwap|Name/{printf $2 " " $3}END{print ""}' $file 2>/dev/null
done | sort -k2 -rn | head -10

High swap usage indicates insufficient RAM. Swap is much slower than RAM since it uses disk storage.

Disk Monitoring

Disk Space

hljs bash
# Disk usage summary
df -h

# Find largest directories
du -sh /* 2>/dev/null | sort -rh | head -10

# Find large files
find / -type f -size +100M -exec ls -lh {} \; 2>/dev/null | sort -k5 -rh | head -10

Disk I/O

hljs bash
# Install iostat
sudo apt install sysstat -y

# Monitor disk I/O
iostat -x 1 5

# Process-level I/O
sudo iotop -o

If disk usage exceeds 90%, performance issues may occur. Above 95% is critical — free up space immediately.

Network Monitoring

hljs bash
# Network interface statistics
ifconfig eth0

# Connection summary
ss -s

# Active connections by IP
ss -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -rn | head -10

# Bandwidth monitoring (requires nload)
sudo apt install nload -y
nload eth0

Quick Health Check Script

hljs bash
#!/bin/bash
echo "=== CPU ==="
top -bn1 | head -5
echo ""
echo "=== RAM ==="
free -h
echo ""
echo "=== DISK ==="
df -h /
echo ""
echo "=== LOAD ==="
uptime
echo ""
echo "=== TOP PROCESSES ==="
ps aux --sort=-%cpu | head -5

When to Contact Support

  • Hardware-level issues suspected
  • Network performance degradation
  • OOM killer repeatedly triggered
  • Unexplained resource consumption