« Previous 1 2
A smoke-jumping admin's best friend
TUI Tools
Writing TUIs
Rather than just present a list of TUI applications that can be used for administration or as everyday applications, I will illustrate that it is fairly straightforward to write these applications, particularly for administration tasks.
A few main libraries or toolkits have been helpful; the first, and probably largest, is curses [19]. Originally written in the late 1970s, curses was optimized and expanded in the early 1980s for the video game Rogue [20]. It then began to be used for a number of applications. Development of curses slowed down, and a new library, ncurses [21], was developed that proved to be more popular than curses. As part of the GNU Project, it is still being developed, although at a slower pace. Figure 1 shows a sample ncurses screenshot.
Another option is Newt [22], a programming library that focuses on color TUIs (Figure 2) and uses a widget approach, making programming a TUI much easier. With Newt, you can create stacked windows, entry widgets, checkboxes, radio buttons, labels, plain text fields, scrollbars, and so on. In Python, this library is referred to as snack and was originally developed for Red Hat's TUI installer, Anaconda.
A number of tutorials on the web can guide you in using Newt with pretty much any desired language. (Sorry, Fortran users, I don't see anything for us yet.) Python is a fairly common language for using Newt (python-snack ), and Jupyter Notebook [23] can help you learn Newt in Python.
Another useful TUI library that can be used with Python and Bash is called dialog [24], which you can use to create pop-up dialog boxes from Bash scripts (Figure 3). Furthermore, dialog has been rolled into a Python library named, aptly enough, pythondialog [25], which allows you to use dialog boxes and other constructs from the dialog library in your Python code.
If you are interested in writing TUIs for system administration, a great place to start is with the psutil
library, which is great for gathering system statistics. Then, you can take a look at the scripts subdirectory [26] on GitHub, where you can find a number of sample scripts for creating a TUI (e.g., the top
clone top.py
[27]). You can also look at other TUIs to understand how to create plots, strip charts, and other useful features. Don't forget, these interfaces are all text based and can be easily used over port 22 (SSH).
Be sure to examine the admin tools mentioned in Table 1. The charting capability, even with just text-based graphics, is great. I love using these tools to get a simple view of how a node is behaving. Take a look at the code and even think about a way to make a function for creating these plots (please create Python interfaces to make life easier).
Summary
A system administrator's job is to keep systems running smoothly and effectively at all times, which means having to triage misbehaving nodes from time to time. In High Performance Computing (HPC), these nodes often don't have a display adapter or have one that is having problems. Being able to log in to the node and use quasi-graphical interfaces over port 22 is a real blessing. You can test applications and monitor the system with the use of TUIs. Although often ignored, believe me, they are very useful in the admin world.
Moreover, TUIs are not difficult to write. With tools from various libraries and the help of online examples, you can create your own custom tool. Python or C is a great way to get started. If you write something or use TUIs on a daily or weekly basis, please give a shout-out on Twitter – I'm sure everyone would love to learn more.
Infos
- bmon: https://www.youtube.com/watch?v=DvjuxPczOFM
- nmon: https://www.youtube.com/watch?v=3PiYabquJBQ
- htop article: https://www.tecmint.com/htop-vs-top-in-linux/
- htop video: https://www.youtube.com/watch?v=ZnEDfqr4Rm0
- iftop: https://www.youtube.com/watch?v=b0eIMkAmBNA
- vtop: https://www.youtube.com/watch?v=y3ylZl-aFFg
- iptraf: https://www.youtube.com/watch?v=cO0huATNxps
- Glances: https://www.youtube.com/watch?v=TQgB0MD9crA
- atop article: https://www.tecmint.com/how-to-install-atop-to-monitor-logging-activity-of-linux-system-processes/
- atop video: https://www.youtube.com/watch?v=PRZTDH9RwT0
- dstat: https://www.youtube.com/watch?v=Fln8KvcOSCs
- psutil: https://www.youtube.com/watch?v=gNl5svb8d-E
- system-config-firewall-tui: https://www.youtube.com/watch?v=PKWgQbQCvR8
- neoleo: https://blippy.github.io/neoleo/
- Midnight Commander: http://midnight-commander.org/wiki/doc
- SC-IM: https://github.com/andmarti1424/sc-im/wiki/Building-SC-IM
- Mutt: http://www.mutt.org/
- ncdu: https://dev.yorhel.nl/ncdu/man
- Curses: https://en.wikipedia.org/wiki/Curses_(programming_library)
- Rogue: https://en.wikipedia.org/wiki/Rogue_(video_game)
- Ncurses: https://en.wikipedia.org/wiki/Ncurses
- Newt: https://en.wikipedia.org/wiki/Newt_(programming_library)
- Jupyter Notebook: http://nbviewer.jupyter.org/gist/shreddd/7589115
- dialog: https://en.wikipedia.org/wiki/Dialog_(software)
- pythondialog: http://pythondialog.sourceforge.net/
- Scripts subdirectory: https://github.com/giampaolo/psutil/tree/master/scripts
- top.py: https://github.com/giampaolo/psutil/blob/master/scripts/top.py
« Previous 1 2
Buy this article as PDF
(incl. VAT)
Buy ADMIN Magazine
Subscribe to our ADMIN Newsletters
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Most Popular
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.