Analyzing Linux server performance with atop
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:
- Shows resource usage of all processes, even those that are closed or completed.
- Monitors threads within processes and ignores processes that are unused.
- Accumulates resource usage for all processes and users with the same name.
- Highlights critical resources using colors (red).
- Adds or removes columns as the size of the display window changes.
- Includes disk I/O and network utilization.
- Uses the
netatopkernel module to monitor TCP, UDP, and network bandwidth.
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:
Install atop on Red Hat Enterprise Linux/CentOS/Fedora Linux
[Want to try out Red Hat Enterprise Linux? Download it now for free.]
yum install atop
Launch it similar to
When it comes to using
atop, a good place to start is to read the man pages:
atop launch commands include:
||Launch with average-per-second total values.|
||Launch with active processes only.|
||Launch with command-line per process.|
||Launch with disk info.|
||Launch with memory info.|
||Launch with network info.|
||Launch with scheduling info.|
||Launch with various info (e.g., PPID, user, or time).|
||Launch with individual threads.|
atop is running, press the following shortcut keys to sort processes:
||Sort in order of most active resources.|
||Revert to sorting by CPU consumption (default).|
||Sort in order of disk activity.|
||Sort in order of memory usage.|
||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:
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.
But, you can limit this output to a specific time window using beginning (
-b) and end (
atopsar -A -b 11:00 -e 11:15
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
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.