Monitoring resource usage
Learn how to monitor system resource usage using the top and atop commands.

This article explains how to track resource usage on a server with top and atop.

Method #1: Use the top command
The traditional way to view resource usage on Linux is with the top program. top provides a real-time overview of system information and running processes, and you can customize the displayed data.

To start top, log in via SSH and run:

top

By default, top refreshes every 3 seconds. You can manipulate the display in many ways; for example, press P to sort tasks by CPU usage.

For detailed information on top, run:

man top

Method #2: Use the atop command
atop is similar to top but offers additional features. It provides a real-time summary with more detailed information and multiple ways to view and filter it. atop also maintains background system activity logs, allowing you to view past resource usage.

To start atop, log in via SSH and run:

atop

When first started, atop may display a lot of information. Key parts of the display include:

  • Top line: Server name, date, and time of the last sample

  • PRC row: General statistics, including time in system calls (sys) and user space (user), number of processes (#proc), and zombie processes (#zombie)

  • CPU and cpu rows: CPU statistics, showing time spent on system calls, user processes, interrupts (irq), idle, and waiting for disks (cpuXXXw)

  • CPL row: Weighted load averages for the past 1, 5, and 15 minutes, plus context switches (csw)

  • MEM row: Memory usage

  • SWP row: Swap memory usage

  • PAG row: Paging frequency

  • DSK row: Disk usage

  • NET rows: Network interface usage

For full reference on atop, run:

man atop

View server activity history
atop maintains activity logs for the past few days. You can load historical data to investigate system performance issues.

  • To view today's activity:

atop -r
  • Move forward through history with t (lowercase) and backward with T (uppercase).

  • To start at a specific time, use the -b option, e.g., to start at 10:15 today:

atop -r -b 10:15
  • To view past days, list files in /var/log/atop and load the desired log file, e.g., March 16, 2025:

atop -r /var/log/atop/atop_20250316

Tip

  • To quickly view yesterday's resource usage:

atop -r y
  • To view the day before yesterday:

atop -r yy
Hjalp dette svar dig? 0 Kunder som kunne bruge dette svar (0 Stem)

Powered by WHMCompleteSolution