S-TUI: Stress-test your CPU
The nifty little S-TUI is an elegant command-line application to monitor your CPU and run a stress test
Use S-TUI to monitor your CPU and run a stress test from the command line
The Linux command-line offers a vast array of useful applications for a host of different use cases. Everything from everyday text editing, connecting with remote machines, performing backups and other administration tasks can be done from the terminal. Monitoring your system’s performance is no exception. Depending on your purpose, you can choose from a variety of dedicated applications to monitor the different components such as CPU frequency, temperature, memory utilisation and so on.
With S-TUI, which is an abbreviation for StressTerminal UI, you can simultaneously monitor CPU temperature, frequency, power and utilisation. It presents all the information graphically and can even be used to export the data into CSV files. Better still, you can configure the tool to automatically launch scripts when the values of any of the components being monitored breaches the defined threshold values. When coupled with stress, another command-line utility, the tool can also stress-test your system.
Not many Linux distributions carry S-TUI in their software repositories, but installation is fairly straightforward. The project’s GitHub page describes various installation techniques. If your system is already configured to use pip, you can install S-TUI with the sudo pip install s-tui command. If you decide to install it from the Git repositories instead, you’ll have to manually install its dependencies – urwid and psutil. You can install these Python packages using your distribution’s package management tool.
You can now begin using the tool to monitor your system’s performance. If you would also like to stresstest the CPU, S-TUI supports both the stress and stress-ng utilities. Most distributions ship these in their software repositories, and you can install them using your distribution’s package management tool.
Unlike many other command-line utilities, S-TUI requires no configuration and you can begin using it immediately after installation. Run the s-tui command to launch the tool. At the top of the sidebar on the left are the details about your CPU. Our Lenovo test machine was correctly identified as Intel Core i3-5005U CPU @ 2.00 GHz. S-TUI uses various other native tools and utilities to gather the relevant information; for instance, the same information, and far greater details, can be ascertained from running the cat /proc/cpuinfo command.
When you first launch S-TUI, it display all four parameters – Frequency, Utilization, Temperature and Power, and refreshes the data for each every second.
You can change the refresh rate by changing the value of Refresh[s]:1.0 on the sidebar.
Depending on your terminal application, and the colour scheme, you may not be able to clearly see the different elements on the S-TUI interface. Should this happen, switch to a basic White-on-Black colour scheme and run S-TUI. This should tell you all the colours used by the tool and you can then make changes to your profile accordingly.
You can navigate the sidebar using the H and J keys, much like you would in vim, or use the Up and Down keys on the keyboard. The default mode for the tool is to monitor your system, which is evident from the (X) next to Monitor on the sidebar. If you installed the stress utility as well, you can enable it by navigating to the Stress entry on the sidebar and pressing Space. You’ll notice the empty brackets are replaced with (X) now.
You can similarly enable or disable monitoring of the different components. When you disable a component, the corresponding graph will automatically disappear from the interface.
Unlike most other command-line utilities, S-TUI can also be controlled with the mouse. Left-click on an entry to select it. You must still hit Escape to return to the main screen and use the arrow keys to scroll through the sidebar, as the scroll-wheel on your mouse won’t work with S-TUI. If for some reason you want to disable the mouse, start S-TUI with s-tui -nm.
You can also switch to a different temperature sensor from within the tool itself, if you believe the graph is inaccurate. Navigate to the Temp Sensors > entry on the sidebar, and press Enter. This opens the Available Temperature Sensors dialogue, and you can then select one from the list. As before, after navigating to an entry in the list, press Spacer to select it. Remember to select Apply for the changes to take effect.
Hit Escape to return to the main screen of the application, such as from the About, Help or Temp Sensors section. While the graphical interface for the tool also has a Help section in the sidebar, it provides little more than a quick introduction. For a complete list of all the supported command options, run s-tui help.
If you want to save the result of the performance monitoring, use s-tui -c. This launches the utility as before, but when you now exit the tool by pressing Q, the collected data will be stored in the user’s home directory. You can then view the s-tui_log_<TIME>.csv file in your preferred text editor. You can also provide a custom name for the CSV log file with s-tui -c <path_to_CSV_file>.
Another useful command option is -j, which can be used to show the current status of the machine in JSON format, like this:
S-TUI supports a number of different temperature sensors and you can choose a different one by navigating to the Temp Sensors screen. This is only needed if the default configuration fails to accurately graph the CPU temperature (for example, if the readings seem significantly way off).
All the basic settings , such as the refresh rate (in seconds), and which components to graph by default are stored in the ~/.config/s-tui/s-tui.conf file. Unfortunately, you must set the Stress options and the temperature sensors manually every time you run S-TUI, as the tool doesn’t permit saving these settings in the configuration file.
In addition to the s-tui.conf file, the ~/.config/s-tui directory contains a directory called hooks-d. Within this directory you can place custom scripts you want to execute when a certain threshold, such as CPU temperature, frequency or similar, is exceeded.
S-TUI supports tracking of four different sources and you can use any of these sources to create custom scripts. The name of the script must be <name>source. sh, where <name> is the name of the supported source. While you can use S-TUI to track various sources, for now it only supports running scripts based on CPU temperature threshold setting.
The default threshold value for the CPU temperature is 80 degrees C. To change this value, invoke S-TUI with s-tui --t_thresh <value>. You can then save the new threshold value into the ~/.config/s-tui/s-tui.conf file by saving the settings from within the tool itself. When you now open the s-tui.conf file in a text editor, you’ll find a new entry showing the newly defined temperature threshold value:
While the stress-testing feature is probably of little use to home and casual Linux users, there’s no denying the benefit of graphical representation of the collected data for administrators and programmers. On the other hand, it’s also a useful way of seeing what’s going on with your CPU if you suspect it’s being throttled in some way, or otherwise not performing as it should.
Above Some information, such as Perf Lost, is only available when you run the tool as root user
Above Enable the ‘Smooth Graph’ option on the sidebar for a better graphical representation of the collected data
Above Refer to the man page and documentation on stress utility to understand its supported functions