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
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.
-
New Steam Client Ups the Ante for Linux
The latest release from Steam has some pretty cool tricks up its sleeve.
-
Gnome OS Transitioning Toward a General-Purpose Distro
If you're looking for the perfectly vanilla take on the Gnome desktop, Gnome OS might be for you.