Lead Image © Thomas Detert, Fotolia.com

Lead Image © Thomas Detert, Fotolia.com

A smoke-jumping admin's best friend

TUI Tools

Article from ADMIN 50/2019
By
Sys admins are like smokejumpers who parachute into fires, fighting them until they are out or at least under control. When you jump into the fire, you only have the tools you brought with you.

The Supercomputing Conference always causes me to reflect on the tools I use for system administration and the tools I would love to have. The most difficult situations I encounter as an admin occur when I can't get the display server to work on a remote system, with no easy way to plug in to a crash cart. Usually, I can SSH to the system and poke around to see what is happening: I'm definitely going to want to test the node to see whether my corrections work. This combination of searching, debugging, and testing over a simple login with SSH is not always easy. Sometimes I miss graphical tools, particularly, if I'm looking at the node's time histories. (My favorite is users swapping the node to death or invoking the dreaded out-of-memory – OOM – error, which is sometimes difficult to find.)

For situations like these, I reach for text-based user interface (TUI) tools. They give me some reasonable graphics while not requiring a display server on the system. TUIs are extremely useful but underrated admin tools, of which I've used many over the years. In this article, I review a few TUI-based admin tools and applications and point out some tools you can use to create your own TUIs to meet your needs.

User Interface

About everyone in the world uses a graphical user interface (GUI) to access their desktops, laptops, and mobile devices. The interface's icons and visual indicators, with some text as a secondary form of input, were developed because command-line interfaces (CLIs) were perceived to be slow and inefficient and could not present graphical images and volumetric data easily. Pretty much every operating system on any device uses a GUI: Windows, macOS, Linux, iOS, Android, desktops, laptops, phones, tablets, ATM machines, and so on. They are the number one way for people to interact with computer systems with a mouse, finger, or stylus.

To utilize a GUI, you need to have some sort of display server on the computer that interacts with a window manager, which is the GUI. These display servers can be quite complicated and require a great deal of computational, memory, network, and disk resources. What happens, though, if the display server misbehaves and you have to debug the problem? How do you interact with the system?

One of the first things I learned as a system administrator is always to have a CLI link to systems, so I can edit configuration files, monitor the system, restart services, read logs, or accomplish any of a host of tasks. Within one month of becoming a system administrator, I had a server go sideways, requiring me to log in remotely to stop and restart some services. Having a CLI connection allowed me to do this.

CLIs respond to a command entered by the user, whereas GUIs respond to a click on an icon, perhaps with a bit of input typed into a dialog. However, if the GUI display server is not behaving well and you want to monitor multiple system metrics over time, a CLI won't necessarily give you the desired results. What you really need is a text-based GUI of some sort – in other words, a TUI.

TUIs

TUIs were named after GUIs. Like GUIs, they display computer graphics, but they do it in text mode, not graphics mode. The more advanced tools allow you to use a mouse or may have multiple, even overlapping, windows.

As a rough approximation, TUIs are sort of in between a CLI and a GUI. They make CLIs more interactive and can present more information. Relative to GUIs, TUIs can be faster, don't require display servers, and can be used over SSH. They also can display time-varying information, unlike a CLI.

Before GUIs became standard, Microsoft DOS applications used TUIs, including WordPerfect, WordStar, QBasic, GW-BASIC, QuickBASIC, and Turbo Pascal, which used Turbo Vision for the TUI. Each had its own TUI library, because operating systems did not have a standard at the time.

Administration tools are the primary TUI users.

TUI Tools

Even today, you can find many examples of TUI applications. They are very fast – faster than GUIs – and easy to use. They help CLI applications that have a large number of options and often provide visual feedback. Many of these tools are widely used, including on HPC systems, to collect statistics across the cluster and manage nodes; they are ideally suited for debugging and testing a small number of nodes.

TUIs are still popular for general applications, although perhaps not so much as administration tools. Nonetheless, they are still used, and new ones are still being developed. Table 1 lists a number of administrative and non-administrative TUIs.

Table 1

Example TUIs

TUI Function Resource
Administrative TUIs
bmon Monitoring and debugging tool designed to capture and display networking statistics capable of text-based plots. A short YouTube video [1] illustrates bmon.
nmon General admin tuner and benchmark tool capable of text-based plots, some of which are almost in real time. A short video on YouTube [2] illustrates how to install and use nmon.
htop Written in C and curses, htop is a very popular replacement tool for top and displays charts at the top of the interface. A good article [3] and a YouTube video [4] explain htop.
iftop Presents network usage for each user in something similar to top format written with the use of libpcap and ncurses. A YouTube video [5] explains a bit about iftop.
vtop A TUI replacement for top written in Node.js with scrolling charts at the top (CPU usage) and the bottom left (memory usage). A good YouTube video [6] presents vtop.
iptraf Provides network statistics. A YouTube video [7] explains iptraf.
Glances A system monitoring tool for providing the maximum information in the minimum amount of space (i.e., it presents a ton of information on the screen). It is written in Python with XML-RPC, has a RESTful JSON API that can be used by other tools, and uses the psutil Python library (see below). Several videos on YouTube discuss Glances usage [8].
atop A TUI performance monitoring tool for Linux. This article on atop [9] is worth reading, as well as a reasonably good YouTube video on installing and using atop [10].
dstat A very well-known admin tool designed to replace vmstat, iostat, netstat, and ifstat in a single tool written in Python and curses. Many tutorials on the web discuss dstat along with some good intros on YouTube [11].
psutil A tool or library for gathering system statistics. It can be used to create all kinds of TUIs for system administration. It is written in Python and has bindings for other languages. It also can be coupled with curses-based plotting if desired. A YouTube video explains some uses for psutil [12].
Non-Administrative TUIs
system-config-firewall-tui This TUI-based firewall could be considered an administrative tool. A good video [13] explains how to use it.
neoleo A text-based spreadsheet built with C and curses. Online documentation [14] walks you through neoleo.
cmus An excellent console music player with an easy-to-use interface written in C and ncurses. This tool offers documentation and a wiki.
Midnight Commander (MC) Probably the most popular TUI-based tool in Linux, this file management tool is written in C and ncurses. Midnight Commander only offers drafts of the documentation project [15].
Vifm A dual-pane file manager written in curses that uses Vi-like bindings. Vifm offers two versions of a man page and a cheatsheet.
SC-IM A text spreadsheet written in C and curses that can use gnuplot for charting. SC-IM offers a wiki on its GitHub page [16].
Mutt A text-based email client that is still very popular. Mutt has online documentation and a wiki [17].
ncdu A curses-based disk usage tool written in C. ncdu has a man-page-style manual [18].

Buy this article as PDF

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

Buy ADMIN Magazine

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

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus
Subscribe to our ADMIN Newsletters
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs



Support Our Work

ADMIN content is made possible with support from readers like you. Please consider contributing when you've found an article to be beneficial.