How to Monitor CPU, Memory, Disk, and Load on Ubuntu Server

How to Monitor CPU, Memory, Disk, and Load on Ubuntu Server

Monitoring CPU utilization, memory consumption, disk I/O, and system load is essential for maintaining performance, diagnosing bottlenecks, and preventing outages on Ubuntu Server. Ubuntu provides excellent built-in tools for real-time and historical insights, with modern alternatives offering richer visualizations.

1. Quick Overview with Built-in Commands

These commands require no additional installation and provide immediate visibility.

  • Load Average (1/5/15-minute averages) The load average represents the number of processes in a runnable or uninterruptible state (waiting for CPU or I/O). On an N-core system, a sustained load > N often signals saturation.
    Bash
    uptime

    Or more precisely:

    Bash
    cat /proc/loadavg
  • CPU, Memory, Processes, and Load – Basic View
    Bash
    top

    Key sections:

    • Top lines: load averages, tasks (total/running/sleeping), %CPU breakdown (%us user, %sy system, %id idle, %wa iowait), memory (total/used/free/buffers/cache).
    • Press 1 to show per-core CPU usage.
    • High %wa indicates disk I/O wait as the bottleneck.
  • Enhanced Interactive View
    Bash
    sudo apt install htop
    htop

    Features color-coded bars for CPU/memory/swap, tree view of processes (F5), kill/send signals (F9), sort by CPU/memory (F6), mouse support.

  • Modern, Beautiful Terminal Dashboard
    Bash
    sudo apt install btop
    btop

    Offers graphical bars, temperature sensors (if available), network throughput, disk usage graphs, and customizable themes—excellent for quick visual assessment of CPU cores, RAM pressure, and I/O activity.

  • All-in-One Cross-Platform Overview
    Bash
    sudo apt install glances
    glances

    Displays CPU (per-core + frequency), load, memory/swap, disk I/O rates (read/write bytes/s), filesystem usage, network bandwidth, Docker/containers (if present), sensors, and processes—all color-coded with alerts (yellow/red thresholds).

2. Disk I/O and Block Device Monitoring

Disk bottlenecks often hide behind high load averages despite low CPU usage.

  • Per-Device I/O Statistics Part of sysstat package:
    Bash
    sudo apt install sysstat
    iostat -x 1  # extended stats, refresh every second

    Focus on:

    • %util → percentage of time the device was busy (close to 100% = saturated)
    • await → average wait time per I/O request (high values indicate queueing)
    • avgqu-sz → average queue length
    • r/s, w/s → reads/writes per second
    • rkB/s, wkB/s → kilobytes read/written per second
  • Per-Process Disk I/O
    Bash
    sudo apt install iotop
    sudo iotop --only  # shows only active I/O processes

    Like top but for DISK READ / DISK WRITE columns—crucial for identifying runaway loggers, backups, or database processes.

  • Virtual Memory & Paging Activity
    Bash
    vmstat 1

    Key columns:

    • si/so → swap in/out (non-zero = thrashing)
    • bi/bo → blocks in/out (disk I/O in 512-byte blocks)
    • wa → % CPU waiting for I/O

3. Historical & Long-Term Monitoring with sar

sar (System Activity Reporter) collects data in background via sadc.

Enable collection (default on Ubuntu Server after sysstat install):

Bash
sudo systemctl enable --now sysstat

Common reports (interval in seconds, count):

  • CPU activity:
    Bash
    sar 1 5                # live
    sar -u -f /var/log/sysstat/saDD  # historical for specific day
  • Memory & swap:
    Bash
    sar -r
  • Disk I/O:
    Bash
    sar -d
  • All major metrics:
    Bash
    sar -A

4. Advanced & Production-Grade Options

For dashboards, alerts, and multi-server monitoring:

  • Netdata — Real-time agent with web UI (localhost:19999), hundreds of charts, ML-based anomaly detection:
    Bash
    bash <(curl -Ss https://my-netdata.io/kickstart.sh)
  • Prometheus + Node Exporter — Metrics collection for alerting/Grafana visualization (standard in Kubernetes/cloud environments).
  • atop — Advanced process accounting with disk/network breakdown.

Start simple: Use uptime → htop/btop/glances for interactive checks → iostat -x + iotop for I/O suspects → sar for trends.

Combine tools for full visibility: high load + low idle CPU + high %util on iostat = disk bottleneck; high load + low %util + swapping = memory pressure.

If you describe your setup (web server, database, container host, bare metal vs VM, etc.) or specific symptoms (e.g., periodic spikes, high iowait), more targeted monitoring strategies can be suggested.

Fast • Reliable • Affordable VPS - DO It Now!

Get top VPS hosting with VPS.DO’s fast, low-cost plans. Try risk-free with our 7-day no-questions-asked refund and start today!