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.

Figure 6: Compact and informative: Even with 80x24 characters, Glances shows a good deal of information. The Akonadi POP3 resource is stressing a CPU core, but Glances itself uses 5.7 percent as /usr/bin/python.

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

 

The Author

Martin Steigerwald works as a system administrator, trainer, and consultant at teamix GmbH in Nuremberg, Germany. He focuses on Linux training (including performance analysis and tuning), as well as evaluating new open source technologies.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • System Status Tools

    A system monitor lets you query the system’s current health state. If you are unhappy with the spartan Top tool, try one of these easy alternatives.

  • Top Ten Tops

    The famous Unix admin utility known as Top has many imitators. We take a look at some of the top Top tools.

  • Glances

    Admins and power users like to watch the load on their computers. Glances lets you see immediately if something is wrong.

  • Nmon

    Administrators often assume that if all nodes are functioning, the system is fine. However, a common problem is poor or unexpected application performance. In this case, you need a simple tool to help you understand what's happening on the nodes: nmon.

  • Bpytop

    Linux users have many options for monitoring system resources, but bpytop, a new Python port of bashtop, more than stands out from the crowd.

comments powered by Disqus

Direct Download

Read full article as PDF:

Price $2.95

News