Monitor Linux CPU temperature, frequency, power in a graphical way

Posted on in Categories Command Line Hacks, Howto, Python last updated December 9, 2017

s-tui
S-tui is a free and open source terminal UI for monitoring your computer. s-tui allows to monitor CPU temperature, frequency, power and utilization in a graphical way from the terminal. It is written in Python and need root permission to use the s-tui. It is useful for:

  1. Watch your CPU temperature/utilization/frequency/power
  2. See performance dips caused by thermal throttling
  3. No need to use X-server. Perfect for headless usage including Raspberry PI

Let us see how to install and use s-tui on a Linux based system.

Step 1 – Install pip

Type the following command to install pip – a package management for Python using apt command/apt-get command:
$ sudo apt install python-pip stress
Sample outputs:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  binutils build-essential cpp cpp-5 dpkg-dev fakeroot g++ g++-5 gcc gcc-5 libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan2 libatomic1 libc-dev-bin libc6-dev libcc1-0 libcilkrts5 libdpkg-perl
  libexpat1-dev libfakeroot libfile-fcntllock-perl libgcc-5-dev libgomp1 libisl15 libitm1 liblsan0 libmpc3 libmpx0 libpython-all-dev libpython-dev libpython-stdlib libpython2.7 libpython2.7-dev libpython2.7-minimal libpython2.7-stdlib
  libquadmath0 libstdc++-5-dev libtsan0 libubsan0 linux-libc-dev make manpages-dev python python-all python-all-dev python-dev python-minimal python-pip-whl python-pkg-resources python-setuptools python-wheel python2.7 python2.7-dev
  python2.7-minimal
Suggested packages:
  binutils-doc cpp-doc gcc-5-locales debian-keyring g++-multilib g++-5-multilib gcc-5-doc libstdc++6-5-dbg gcc-multilib autoconf automake libtool flex bison gdb gcc-doc gcc-5-multilib libgcc1-dbg libgomp1-dbg libitm1-dbg libatomic1-dbg
  libasan2-dbg liblsan0-dbg libtsan0-dbg libubsan0-dbg libcilkrts5-dbg libmpx0-dbg libquadmath0-dbg glibc-doc libstdc++-5-doc make-doc python-doc python-tk python-setuptools-doc python2.7-doc binfmt-support
The following NEW packages will be installed:
  binutils build-essential cpp cpp-5 dpkg-dev fakeroot g++ g++-5 gcc gcc-5 libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan2 libatomic1 libc-dev-bin libc6-dev libcc1-0 libcilkrts5 libdpkg-perl
  libexpat1-dev libfakeroot libfile-fcntllock-perl libgcc-5-dev libgomp1 libisl15 libitm1 liblsan0 libmpc3 libmpx0 libpython-all-dev libpython-dev libpython-stdlib libpython2.7 libpython2.7-dev libpython2.7-minimal libpython2.7-stdlib
  libquadmath0 libstdc++-5-dev libtsan0 libubsan0 linux-libc-dev make manpages-dev python python-all python-all-dev python-dev python-minimal python-pip python-pip-whl python-pkg-resources python-setuptools python-wheel python2.7
  python2.7-dev python2.7-minimal
0 upgraded, 57 newly installed, 0 to remove and 0 not upgraded.
Need to get 73.4 MB of archives.
After this operation, 209 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libpython2.7-minimal amd64 2.7.12-1ubuntu0~16.04.2 [338 kB]
....
..
...
Setting up libalgorithm-merge-perl (0.08-3) ...
Setting up libexpat1-dev:amd64 (2.1.0-7ubuntu0.16.04.3) ...
Setting up libfile-fcntllock-perl (0.22-3) ...
Setting up libpython2.7:amd64 (2.7.12-1ubuntu0~16.04.2) ...
Setting up libpython2.7-dev:amd64 (2.7.12-1ubuntu0~16.04.2) ...
Setting up libpython-dev:amd64 (2.7.11-1) ...
Setting up libpython-all-dev:amd64 (2.7.11-1) ...
Setting up manpages-dev (4.04-2) ...
Setting up python-all (2.7.11-1) ...
Setting up python2.7-dev (2.7.12-1ubuntu0~16.04.2) ...
Setting up python-dev (2.7.11-1) ...
Setting up python-all-dev (2.7.11-1) ...
Setting up python-pip-whl (8.1.1-2ubuntu0.4) ...
Setting up python-pip (8.1.1-2ubuntu0.4) ...
Setting up python-pkg-resources (20.7.0-1) ...
Setting up python-setuptools (20.7.0-1) ...
Setting up python-wheel (0.29.0-1) ...
Processing triggers for libc-bin (2.23-0ubuntu9) ...

Step 2 – Install s-tui

Type the following command to install it:
$ sudo pip install s-tui

Collecting s-tui
  Downloading s-tui-0.6.7.2.tar.gz
Collecting urwid>=1.3.1 (from s-tui)
  Downloading urwid-1.3.1.tar.gz (588kB)
    100% |████████████████████████████████| 593kB 558kB/s 
Collecting psutil>=5.2.0 (from s-tui)
  Downloading psutil-5.4.2.tar.gz (411kB)
    100% |████████████████████████████████| 419kB 646kB/s 
Installing collected packages: urwid, psutil, s-tui
  Running setup.py install for urwid ... done
  Running setup.py install for psutil ... done
  Running setup.py install for s-tui ... done
Successfully installed psutil-5.4.2 s-tui-0.6.7.2 urwid-1.3.1

Arch Linux users can type the following command to install it:
$ sudo yaourt -S s-tui

Step 3 – Use it

Simply type the following command:
$ sudo s-tui
Sample outputs:

Gif. 01: s-tui in action
Gif. 01: s-tui in action

Getting help

s-tui has many more option. Type the following command to see them:
$ s-tui --help
Sample outputs:

usage: s-tui [-h] [-d] [-c] [-t] [-j] [-nm] [-v] [-ct CUSTOM_TEMP]
             [-cf CUSTOM_FAN]
 
TUI interface:
 
The side bar houses the controls for the displayed grahps.
At the bottom of the side bar, more information is presented in text form.
 
* Use the arrow keys or 'hjkl' to navigate the side bar
* Toggle between stressed and regular operation using the radio buttons in 'Modes'.
* If you wish to alternate stress defaults, you can do it in 'Stress options'
* Select a different temperature sensors from the 'Temp Sensors' menu
* Change time between updates using the 'Refresh' field
* Use the <Reset> button to reset graphs and statistics
* Toggle displayed graphs by selecting the [X] check box
* If a sensor is not available on your system, N/A is presented
* If your system supports it, you can use the utf8 button to get a smoother graph
* Press 'q' or the <quit> button to quit
 
* Run `s-tui --help` to get this message and additional cli options
 
optional arguments:
  -h, --help            show this help message and exit
  -d, --debug           Output debug log to _s-tui.log
  -c, --csv             Save stats to csv file
  -t, --terminal        Display a single line of stats without tui
  -j, --json            Display a single line of stats in JSON format
  -nm, --no-mouse       Disable Mouse for TTY systems
  -v, --version         Display version
  -ct CUSTOM_TEMP, --custom_temp CUSTOM_TEMP
                        Custom temperature sensors.
                        The format is: <sensors>,<number>
                        As it appears in 'sensors'
                        e.g
                        > sensors
                        it8792-isa-0a60,
                        temp1: +47.0C
                        temp2: +35.0C
                        temp3: +37.0C
 
                        use: -ct it8792,0 for temp 1
 
  -cf CUSTOM_FAN, --custom_fan CUSTOM_FAN
                        Similar to custom temp
                        e.g
                        >sensors
                        thinkpad-isa-0000
                        Adapter: ISA adapter
                        fan1:        1975 RPM
 
                        use: -cf thinkpad,0 for fan1

For more information see s-tui project home page.

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Share this on (or read 4 comments/add one below):

4 comment

  1. I’ve got mostly 17.10 machines – but they’re not “consistent” – install worked flawlessly on a build of 17.10 fresh install – but ran into issues on couple of machines that started “life” as 16.x – then up’d to 17.04 then 17.10.
    Ended up just copying “working” /usr/local/bin/s-tui to each of them.
    Instructions also worked flawlessly on an iMac running Xubuntu 16.04 LTS…
    Also – didn’t/doesn’t seem to work at all on a banapi running “latest” Armbian – but – worked flawlessly as per instructions on a RaspberryPi 3B+ running Stretch / Raspbian… :-D

  2. pip install s-tui
    Traceback (most recent call last):
    File “/usr/bin/pip”, line 11, in
    sys.exit(main())
    File “/usr/lib/python2.7/dist-packages/pip/__init__.py”, line 215, in main
    locale.setlocale(locale.LC_ALL, ”)
    File “/usr/lib/python2.7/locale.py”, line 581, in setlocale
    return _setlocale(category, locale)
    locale.Error: unsupported locale setting

  3. In my case the following commands were necessary for it to install properly:

    1) sudo aptitude install python-pip stress python-setuptools build-essential python-dev

    2) sudo pip install –upgrade pip

    3) sudo pip install s-tui

    …And I was able to give it a launcher in KDE using the following:

    KDE LAUNCHER:
    (None checked in ‘Advanced’ tab, eg. “Run in terminal” or “Run as a different user”)
    ‘Command’ field:
    echo password | sudo -S konsole -e s-tui

  4. Hey, mine was successfully installed and running perfectly fine. however, the problem is i’m trying to figure out why temperature and power currently N/A? any idea to resolve this? appreciated for the response

Comments are closed.