Skip to main content

Analyzing Linux server performance with atop

The atop command displays you a more anatomized view of your server's performance.
Image
Analyzing Linux performance with atop
"Spinning Top" by russellstreet is licensed under CC BY-SA 2.0

We’re all familiar with top, a real-time system monitor which shows usage of your Linux hardware and network resources. As a top command alternative, atop also provides sysadmins with real-time system insight, and also allows for an anatomized view of which processes are using the most CPU, memory, storage, or network.

Let’s take a look at using atop for Linux server performance analysis.

Advantages of atop

Atop is an ASCII, full-screen performance monitor which can log and report the activity of all server processes. One feature I really like is that atop stays active in the background for long-term server analysis (up to 28 days by default). Other advantages include:

Once atop is launched, by default it shows system activity for CPU, memory, swap, disks, and network in 10-second intervals. In addition, for each process and thread, you can analyze CPU utilization, memory consumption, disk I/O, priority, username, state, and even exit codes:

Image
The atop command's default screen.

Install atop on Red Hat Enterprise Linux/CentOS/Fedora Linux

[Want to try out Red Hat Enterprise Linux? Download it now for free.]

First, install and enable the Extra Packages for Enterprise Linux (EPEL) repo. See Red Hat solution #308983 if you’re not sure how to do this. Once that task is complete, you can install atop:

yum install atop

Launch it similar to top, using:

atop

Using atop

When it comes to using atop, a good place to start is to read the man pages:

man atop

Useful atop launch commands include:

Command Description
atop -1 Launch with average-per-second total values.
atop -a Launch with active processes only.
atop -c Launch with command-line per process.
atop -d Launch with disk info.
atop -m Launch with memory info.
atop -n Launch with network info.
atop -s Launch with scheduling info.
atop -v Launch with various info (e.g., PPID, user, or time).
atop -y Launch with individual threads.


Once atop is running, press the following shortcut keys to sort processes:

Shortcut key Description
a Sort in order of most active resources.
c Revert to sorting by CPU consumption (default).
d Sort in order of disk activity.
m Sort in order of memory usage.
n Sort in order of network activity.

​​​​​

Reading atop reports and logs

By default, after installation, the atop daemon writes snapshots to a compressed log file (e.g., /var/log/atop/atop_20140813). These log files can be read using:

atop -r </full/path/to/atop/log/file>

Once you open a log file (e.g., atop -r /var/log/atop/atop_20140813), then use t to go forward in 10-minute intervals, and T to go back. You can analyze specific times by pressing b and then entering the time. The above shortcut keys also work in this mode: a, c, d, m, and n.

You can use shortcuts with atopsar. For example, using the flag -c 30 5 with atopsar generates a report for current CPU utilization for five minutes (10 times with intervals of 30 seconds):

atopsar -c 30 5

Using the flag -A with return all available reports.

atopsar -A

But, you can limit this output to a specific time window using beginning (-b) and end (-e) flags:

atopsar -A -b 11:00 -e 11:15

Wrapping Up

There are some good advantages and unique features of atop, as listed above. Personally, I like how atop allows you to isolate and analyze CPU usage, memory consumption, storage I/O, etc., for each process and thread.

Still, some of us will continue to prefer top or htop, and they are both great tools. After reading this article, I hope more people will also add or continue to use atop as one of their go-to Linux analysis and troubleshooting tools.

Topics:   Linux  
Author’s photo

Hayden James

Hayden James is a Linux Systems Analyst and Internet Entrepreneur from the Caribbean. He relocated to the US ten years ago, where he maintained Linux servers and sold small startups. Today, he supports clients remotely from his island home while also managing a niche web hosting venture. More about me

Related Content

OUR BEST CONTENT, DELIVERED TO YOUR INBOX