以图形方式监控 Linux CPU 温度、频率、功率


-tui 是一个免费的开源终端用户界面,用于监控您的计算机。 s-tui 允许从终端以图形方式监控 CPU 温度、频率、功率和利用率。 它是用 Python 编写的,需要 root 权限才能使用 s-tui。 它适用于:

  1. 观察您的 CPU 温度/利用率/频率/功率
  2. 查看由热节流引起的性能下降
  3. 无需使用 X 服务器。 非常适合无头使用,包括 Raspberry PI

让我们看看怎样在基于 Linux 的系统上安装和使用 s-tui。

第 1 步 – 安装 pip

输入以下命令来安装 pip——使用 apt 命令/apt-get 命令的 Python 包管理:
$ sudo apt install python-pip stress

示例输出:

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 https://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) ...

步骤 2 – 安装 s-tui

输入以下命令进行安装:
$ 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 用户可以输入以下命令进行安装:
$ sudo yaourt -S s-tui

第 3 步 – 使用它

只需键入以下命令:
$ sudo s-tui

示例输出:

获得帮助

s-tui 有更多选择。 键入以下命令以查看它们:
$ s-tui --help

示例输出:

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

有关更多信息,请参阅 s-tui项目主页.

相关阅读:

Posted in: LinuxTags: ,