Monitoring server CPU, RAM and disk usage

Monitor your server's CPU, RAM, and disk usage precisely with top, htop, df, and iostat. Learn to interpret the numbers, avoid common mistakes, and use practical commands in this guide.

7 min Updated 21 Aug 2026

Why Is Server Resource Monitoring Critical?

Every server, whether a small VPS or a large data center, has limited resources. When CPU, RAM, or disk usage exceeds a certain threshold, application performance degrades, website responsiveness slows down, and in the worst case, the server goes offline. Server resource monitoring helps you identify and resolve issues before users even notice them. In this article, we'll explore four essential Linux tools—top, htop, df, and iostat—and learn how to interpret their output numbers.

The top Tool: A Real-Time Overview of Resource Usage

The top command is the oldest and most accessible server resource monitoring tool. It comes pre-installed on almost all Linux distributions and provides a live view of CPU, RAM, and running processes.

Reading top Output

When you run top in the terminal, you'll see two main sections: a system summary at the top and a process table at the bottom. The first line includes uptime, number of users, and the load average. The load average shows three numbers: the average load over the last 1, 5, and 15 minutes. If these numbers exceed the number of CPU cores, the system is working beyond its capacity.

The second and third lines show process status and CPU usage, respectively. In the CPU line, you'll see the following values:

  • us: Percentage of CPU used by user processes
  • sy: Percentage of CPU used by the system kernel
  • id: Percentage of idle CPU
  • wa: Percentage of time waiting for disk I/O

If the wa value is high (e.g., above 20%), it means the server's disk is slow, and the CPU is waiting for input/output operations. This is one of the most important signs to watch for in server resource monitoring.

Useful Commands in top

While top is running, you can use the following keys:

  • P: Sort by CPU usage
  • M: Sort by RAM usage
  • k: Kill a process by entering its PID
  • q: Quit the program

For a one-time, non-interactive output, use the following command:

top -b -n 1 | head -n 20

This command prints a single snapshot of the output without the interactive mode and is very useful for automated scripts.

Common Mistake: Many users only look at the CPU percentage and ignore the wa value. If wa is high but the CPU appears idle, the problem isn't the processor—it's the disk or network.

The htop Tool: Better Interface for Server Resource Monitoring

htop is an improved version of top that provides a colorful interface, visual progress bars, and mouse navigation. Although it's not pre-installed on all systems, installation is straightforward:

# Debian/Ubuntu
sudo apt install htop

# RHEL/CentOS
sudo yum install htop

Advantages of htop Over top

In htop, colored bars at the top of the screen show the usage of each CPU core separately. The colors have specific meanings: red for user processes, green for system processes, and blue for low-priority processes. This visual distinction helps you quickly understand which part of the system is under the most pressure.

At the bottom of the screen, you'll also see memory (RAM) and Swap usage bars. An important point is that in Linux, memory not used by applications is used as cache for the disk. So if the used value is high but cache is also high, there's no cause for concern—the system is using memory optimally.

Working with the Process Tree

One of the useful features of htop is the tree view of processes. By pressing the F5 key, you can see which parent process has spawned its children. This feature is very practical for finding the root cause of resource consumption issues. For example, if an Apache web server has created hundreds of child processes, the tree view clearly shows that they all originate from a single main process.

The df Tool: Monitoring Disk Space

Disk space is one of those resources where shortages are often noticed too late. The df (Disk Free) command shows information about the used and available space on each partition.

Basic df Commands

The simplest way to use df is:

df -h

The -h option (human-readable) displays sizes in an understandable format (GB, MB). The output includes the following columns:

  • Filesystem: The name of the partition or device
  • Size: Total size of the partition
  • Used: Used space
  • Avail: Available space
  • Use%: Percentage used
  • Mounted on: The mount point (e.g., / or /home)

For periodic server resource monitoring, you can use cron and send an email alert if the usage percentage exceeds a threshold (e.g., 85%):

df -h | awk 'NR>1 {gsub(/%/,"",$5); if ($5 > 85) print $0}'

Identifying Large Files

When the disk fills up, you need to know what's taking up the space. The du (Disk Usage) command helps here:

sudo du -sh /var/log/*
sudo du -h --max-depth=1 /home | sort -hr | head -n 10

The first command shows the size of each file in the /var/log directory, and the second command sorts the largest directories inside /home. Log files are usually the biggest culprit for filling up disks, so regularly checking them is an important part of server resource monitoring.

Common Mistake: Deleted files that are still open by processes occupy disk space. If df shows low space but du doesn't find any large files, check for this issue:

lsof +L1 | head -n 20

This command shows deleted files that are still being used by processes.

The iostat Tool: Deep Analysis of Disk Performance

iostat is part of the sysstat package and provides detailed information about disk I/O performance. This tool is essential for server resource monitoring when the disk is slow or you suspect a bottleneck.

Installation and Basic Usage

# Debian/Ubuntu
sudo apt install sysstat

# RHEL/CentOS
sudo yum install sysstat

The simplest usage:

iostat -x 2 3

This command displays output every 2 seconds, 3 times total, with the -x (Extended) option. Important columns in the output include:

  • %util: The percentage of time the disk was busy performing operations. If this value approaches 100%, the disk is fully saturated.
  • await: The average response time of the disk to requests (milliseconds). Values above 20 ms for HDDs and above 5 ms for SSDs indicate a problem.
  • r/s and w/s: The number of read and write operations per second.
  • rkB/s and wkB/s: The amount of data read and written per second.

Interpreting iostat Numbers

Suppose you see the following output:

Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s await %util
sda       0.00   12.00 0.00 45.00 0.00 560.00 18.50 85.00

This output shows that the sda disk is busy 85% of the time, with an average wait time of 18.5 milliseconds. These values are on the warning threshold for a typical HDD. If %util reaches 100%, the disk can no longer handle more requests, and you should consider upgrading hardware or optimizing applications.

Continuous Monitoring with sar

The sysstat package also includes the sar tool, which can collect historical data. To enable automatic data collection:

sudo systemctl enable sysstat
sudo systemctl start sysstat

Then you can view yesterday's report:

sar -d -f /var/log/sysstat/sa$(date +%d -d yesterday)

This historical report helps you analyze disk usage trends over time and identify peak usage patterns.

Summary: A Complete Strategy for Server Resource Monitoring

No single tool can meet all your server resource monitoring needs. The best approach is to intelligently combine these four tools:

  1. Use htop for a quick view of real-time CPU and RAM status.
  2. Use top in automated scripts and when you need a lighter tool.
  3. Check disk space daily with df and set up automatic alerts.
  4. Use iostat for deep analysis of disk performance and bottleneck identification.

Remember that server resource monitoring is not a one-time task but an ongoing process. Record the numbers, track trends, and take action before problems become critical. If you need a scalable and reliable infrastructure, ServerNet offers a wide range of hosting services on which you can confidently run your applications. But more important than choosing a service is learning how to manage your resources—and this guide was your first step on that path.

Was this page helpful?