Comparing the Top, Htop, Atop, and Glances system monitors
Recording Measured Values
Atop's ability to record measured values proves to be particularly useful. By default it does so every 10 minutes. To change the interval, you either modify the DARGS
parameter shown in the first line of Listing 1 in the /etc/init.d/atop
init script, or the ExecStart
statement from the second line of Listing 1 in the /etc/systemd/system/multi-user.target.wants/atop.service
Systemd service file. Change the 600
seconds to the desired value. Alternatively, you can start Atop with a shorter interval whenever needed (e.g.,
Listing 1
Changing Atop's Default Interval
atop -w /var/tmp/my-atop.log 10
tells Atop to sample with a 10-scond interval). Pay attention to the storage space usage on the disk.
Atopsar either measures in real time or reports on stored performance data. For example, atopsar -d 1 10
creates 10 measurements of disk usage at intervals of one second. Atop also has the ability to show only the shared resources – this is especially helpful if you have many installed drives, CPUs, or network cards.
With the appropriate options, as summarized in the man page, Atopsar shows reports on processor, memory, and network-related values. If you use the -b
and -e
parameters to define the start and end times, Atopsar instead parses the current log in /var/log/atop
. You can specify another file with -r
.
Atopsar also creates reports on a per process basis: For example, -O
, -G
, -D
, or (if you have a patched kernel) -N
each show the three processes that use the most CPU time, resident memory, disk I/O, or IPv4/IPv6 network traffic. These reports are not available for live measurements, however.
The ability to interactively browse a logfile with Atop, using the -r
option, is also very interesting. You can then view the recorded values as if they were live. Pressing t scrolls forward, and T scrolls back.
Glances
The newcomer among Top programs, the Python-based Glances tool, accesses the psutil
library to query system information [8]. On Debian "Jessie" or "Sid," Ubuntu as of 13.04, and Fedora, you simply install the Glances package. The package for SUSE is in the openSUSE build service [9].
The glances
command starts the program in normal mode, and glances -s
switches to server operation. In this mode, Glances listens for requests on port 61209 for all of the system's IP addresses. The -B
option lets you specify an IP address, whereas -p
lets you define a different port. The Glances client connects to the server using glances -c <IP address>
. The --password
option lets you set a password on the server; you need to specify this again when you connect with the client. Whatever option you choose, the system data is transferred unencrypted over the wire.
Even with a terminal size of just 80x24 characters, Glances displays a slew of information: In the header section, you see the CPU and memory usage, as well as the system load (Figure 6). On the left side, the program gives an overview of the network and disk transfer rates, as well as the filesystem fill levels. On the right side, Glances displays the process list. In a larger window, the program gives you additional details in the header and process list, such as some supplementary information on the CPU load, the total CPU time used, or the disk I/O per process.
Pressing c sorts the processes by CPU time, m sorts by memory usage, i by disk I/O, and p by name. As in Atop, pressing a tells Glances to sort by the most commonly used resource. More options for showing and hiding various display elements are revealed by the help feature (h).
If the window is large enough, Glances shows an event log containing the last three warnings or critical alarms. The configurable limits for the OK
, CAREFUL
, WARNING
, and CRITICAL
levels are explained by the documentation. You can export to a CSV file with the following command:
$ glances --output-csv <file>
This gives you an option for importing the values into a spreadsheet. Glances uses a different separator for the column names than for the individual values. Using a comma and the pipe character |
gives you a readable import.
Another useful Glances function lets you monitor process groups, which is explained in the documentation below Monitored Processes List.
Conclusions
All of the Top variants discussed here have specific advantages and disadvantages. Glances impresses with its compact view, event log, and (web) server operation. Htop and Top offer extensive configurability in terms of the fields displayed.
My personal favorite is still Atop, however; it shows you precisely the details that are currently relevant and leaves out things that don't really matter. In particular, the logging function, with the ability to create reports and interactively scroll through records, proves to be a big bonus.
Manually Installing Glances
Until the distributors packetize the freshly released 2.0 version, you can alternatively install Glances via the Python Package Index (PyPI). To do so, you first need to install the python-pip package on Debian, Ubuntu, or SUSE and then run the
pip install glances
command. To update, type:
pip install --upgrade glances
Then,
pip uninstall glances psutil
removes the program again. In case of a parallel installation with the distribution package, /usr/bin/glances
launches the distribution version and /usr/local/bin/glances
or just glances
launches the version installed via PyPI.
You can also manually install Glances. To do so, download the latest source code from Git (Listing 2, line 1) and install as shown in line 2. You can also remove Glance manually if necessary (line 3).
As a special gimmick, pip install bottle
gives you the option of viewing the output from Glances in your web browser. That said, Iceweasel version 30 used about 13 percent of the processing power of one core on a 2.5GHz Intel Sandybridge CPU (i5-2520 M) to do so.
Glances is relatively CPU hungry all told: Whereas Top and Htop and Atop are hardly noticeable on the CPU meter, clocking 0.5 to 1.5 percent, Glances in standalone or client-server mode uses between five and six percent given a refresh interval of three seconds. If you additionally want to see the LM sensors, call pip install PySensors
.
Listing 2
Downloading Glances
Infos
- Procps: http://procps.sourceforge.net
- Procps-ng: https://gitorious.org/procps
- Htop: http://hisham.hm/htop
- Atop: http://atoptool.nl
- Glances: https://github.com/nicolargo/glances
- Server monitoring project: http://download.opensuse.org/repositories/server:/monitoring/
- NetHogs: http://nethogs.sourceforge.net/
- Glances documentation: https://github.com/nicolargo/glances/blob/master/docs/glances-doc.rst
- Glances package from the openSUSE build service: http://software.opensuse.org/package/glances
- Stress: http://people.seas.harvard.edu/~apw/stress/
« Previous 1 2
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Canonical Releases Ubuntu 24.04
After a brief pause because of the XZ vulnerability, Ubuntu 24.04 is now available for install.
-
Linux Servers Targeted by Akira Ransomware
A group of bad actors who have already extorted $42 million have their sights set on the Linux platform.
-
TUXEDO Computers Unveils Linux Laptop Featuring AMD Ryzen CPU
This latest release is the first laptop to include the new CPU from Ryzen and Linux preinstalled.
-
XZ Gets the All-Clear
The back door xz vulnerability has been officially reverted for Fedora 40 and versions 38 and 39 were never affected.
-
Canonical Collaborates with Qualcomm on New Venture
This new joint effort is geared toward bringing Ubuntu and Ubuntu Core to Qualcomm-powered devices.
-
Kodi 21.0 Open-Source Entertainment Hub Released
After a year of development, the award-winning Kodi cross-platform, media center software is now available with many new additions and improvements.
-
Linux Usage Increases in Two Key Areas
If market share is your thing, you'll be happy to know that Linux is on the rise in two areas that, if they keep climbing, could have serious meaning for Linux's future.
-
Vulnerability Discovered in xz Libraries
An urgent alert for Fedora 40 has been posted and users should pay attention.
-
Canonical Bumps LTS Support to 12 years
If you're worried that your Ubuntu LTS release won't be supported long enough to last, Canonical has a surprise for you in the form of 12 years of security coverage.
-
Fedora 40 Beta Released Soon
With the official release of Fedora 40 coming in April, it's almost time to download the beta and see what's new.