Next-generation terminal UI tools
Cursed Monitor
The venerable curses [1] library first enabled plotting graphics on a Unix terminal, allowing the emergence of dynamic, interactive tools such as top
[2] and its brood of descendants to improve greatly the ability to monitor a system's state continuously. The transition from static tables of numbers to charts and sometimes even dynamic data representations was followed by new implementations of terminal user interface (TUI) libraries, including Ncurses [3] and Newt [4]. Jeff Layton has previously graced these pages with a tutorial on how TUI tools are developed today [5], and yours truly followed in the next issue with a survey of network monitoring tools adopting in-terminal graphics [6]. Two years later, I revisit the subject to witness the impressive improvement of the state of the art taking place since.
Not Your Father's Curses
The bashtop
[7] utility is one of the most remarkable new entrants – so much so it has been featured by the likes of Forbes
magazine [8], hardly what I would call conventional treatment for a Linux utility. Originally written in Bash (hence its name), it was re-implemented in Python [9] last year, reducing its CPU consumption by two-thirds and simultaneously improving speed and extending functionality. A third rewrite, this time in C++, is in progress at the time of this writing. The performance enhancements are welcome for administrators who leave the tool running in the background, but all versions of the tool are equally suitable for intermittent use – just keep in mind that newer ports provide additional functionality not found in the original; for example, mouse support absent in the Bash version has been added with the Python port.
Bashtop (Figure 1) supports both Linux and macOS (when used with iTerm2 [10]) and is controlled from the keyboard. (Menu entries are keyed by letters highlighted in grey.) The Python port is available as part of the Ubuntu standard repositories [11] starting with Ubuntu 20.10 (Groovy Gorilla), whereas the original Bash implementation is easily built on stock 20.04 (Focal Fossa) from the author's repository with sudo make install
.
In its default configuration, Bashtop provides a ranked process listing including memory and CPU usage, as well as system-wide aggregate status for CPU, memory, permanent storage, and network connections. The configuration screen features a retro arcade game look, speaking to the author's attention to detail (Figure 2).
A more practical nod to UX is the fading out of process listing entries as you get farther from the top, and the increased brightness of entries as they approach 100 percent. Although the tool can be used to monitor systems with many disks or network connections, the most striking visualization is reserved for CPU load history (Figure 3). It presents a history ribbon view of the CPU, breaks out individual cores, and includes load average [12] figures. Network interfaces benefit from a similar visualization (Figure 4), with the Python implementation bpytop
extending the treatment to memory use, as well (Figure 5).
At a Glance
The older glances
[13] tool might not push the limits of TUI graphics as aggressively as its newer challenger, but it more than makes it up in portability and extensibility. Supporting Linux, Solaris, *BSD, macOS, and even Windows, glances
is my go-to system monitoring: I quite simply install it everywhere (Figure 6). Take note to use binaries where a build is available, because like many other highly portable applications, a build of Glances can take quite some time to complete on account of its many dependencies. On macOS, I use brew install glances
as a stress generator for new hosts, akin to running a kernel build on Linux. Glances can also provide remote monitoring when needed (both as a web application and in client-server mode), although I choose SSH when the occasion calls for remote access.
Alongside processes listing and network, disk, and CPU system metrics, a glances
summary screen can display sensor data, notably for CPU and disk temperatures, which is critical information for servers. Sensor instrumentation can include other plugins, such as battery charge levels on laptops. A unique capability of glances
is its built-in container monitoring, putting Docker containers on equal footing with Linux processes, making it very interesting in modern environments with containerized applications (Figure 7). Glances itself is available as a Docker image with the one-liner docker pull nicolargo/glances
.
Network Watch
The venerable ping
[14] tool has also received a TUI facelift – two in fact. The prettyping
[15] Bash and Awk wrapper for the original tool requires no installation and no special permissions but greatly enhances the visibility of latency variance or the appearance of spurious errors while tracking aggregate statistics for the last 60 packets (Figure 8). On packet loss, prettyping
breaks to a new line and highlights latency changes with a predefined color scale.
Less apt at highlighting failures, but impressive at charting change in latency, is the newfangled gping
[16], which charts latency in what is perhaps the best dynamically resizing in-terminal graph to date (Figure 9). The gping
tool pushes the limits of in-terminal graphs, and it is perfectly suited to examining continuous changes in network performance, as opposed to highlighting spurious events.
Infos
- Curses: https://en.wikipedia.org/wiki/Curses_(programming_library)
- top(1) man page: https://manpages.ubuntu.com/manpages/focal/en/man1/top.1.html
- Ncurses: https://en.wikipedia.org/wiki/Ncurses
- Newt: https://en.wikipedia.org/wiki/Newt_(programming_library)
- "TUI Tools" by Jeff Layton, ADMIN , issue 50, 2019, https://www.admin-magazine.com/Archive/2019/50/A-smoke-jumping-admin-s-best-friend
- "Network Performance In-Terminal Graphics Tools" by Federico Lucifredi, ADMIN , issue 51, 2019, https://www.admin-magazine.com/Archive/2019/51/Network-performance-in-terminal-graphics-tools
- Bashtop: https://github.com/aristocratos/bashtop
- "You Need This Beautiful Linux and MacOS App in Your Terminal" by Jason Evangelho, Forbes , Aug 2020, https://www.forbes.com/sites/jasonevangelho/2020/08/05/meet-the-most-beautiful-linux-app-you-need-in-your-terminal/
- Bpytop: https://github.com/aristocratos/bpytop
- iTerm2 for macOS: https://iterm2.com/
- bashtop(1) man page: https://manpages.ubuntu.com/manpages/groovy/en/man1/bashtop.1.html
- "The Iconic Load Average Metric" by Federico Lucifredi, ADMIN , issue 11, 2012
- Glances: https://github.com/nicolargo/glances
- ping(1) man page: https://manpages.ubuntu.com/manpages/focal/en/man1/ping.1.html
- prettyping, Denilson Sá Maia blog: http://denilson.sa.nom.br/prettyping/
- gping: https://github.com/orf/gping
Buy this article as PDF
(incl. VAT)