如何在Linux中找到适用于CPU和GPU的风扇速度

时间:2020-01-09 14:17:09  来源:igfitidea点击:

如何输入什么命令才能找出Linux中GPU和CPU的风扇速度?
您需要使用Linux监视传感器软件lm_sensors。
它是一个开源软件,提供用于监视CPU/GPU温度,电压和风扇速度的命令和驱动程序。
一旦安装了lm_sensors,我们就可以使用KDE或GNOME的系统监视器GUI前端来获取数据。
让我们看看如何使用CLI在Linux操作系统上安装lm_sensors并找出风扇速度。

如何在Linux中找到风扇速度

在Linux上查找风扇速度的过程如下:

  • 首先,使用软件包管理器安装" lm-sensors"软件包。
  • 通过运行sudo sensor-detect命令配置传感器。
  • 保存配置文件
  • 最后,在Linux中运行" sensors"命令以查看CPU和GPU温度,包括风扇速度。

让我们详细查看所有命令和示例。

如何安装lm传感器

根据您的Linux发行版执行命令。

CentOS/RHEL/Oracle Linux

使用yum命令,如下所示:

sudo yum install lm_sensors

Fedora Linux

输入dnf命令:

sudo dnf install lm_sensors

Debian/Ubuntu/Mint Linux

执行apt命令/apt-get命令:

sudo apt-get install lm-sensors

OpenSuse/Suse Linux

输入以下zypper命令:

sudo zypper in sensors

输出示例:

The following 2 NEW packages are going to be installed:
  libsensors4 sensors
 
2 new packages to install.
Overall download size: 167.9 KiB. Already cached: 0 B. After the operation,
additional 472.9 KiB will be used.
Continue? [y/n/v/...? shows all options] (y): y
Retrieving package libsensors4-3.5.0-4.3.1.x86_64
                                          (1/2),  53.8 KiB (105.2 KiB unpacked)
Retrieving: libsensors4-3.5.0-4.3.1.x86_64.rpm ..........................[done]
Retrieving package sensors-3.5.0-4.3.1.x86_64
                                          (2/2), 114.1 KiB (367.7 KiB unpacked)
Retrieving: sensors-3.5.0-4.3.1.x86_64.rpm ..............................[done]
 
Checking for file conflicts: ............................................[done]
(1/2) Installing: libsensors4-3.5.0-4.3.1.x86_64 ........................[done]
(2/2) Installing: sensors-3.5.0-4.3.1.x86_64 ............................[done]

Arch Linux

执行pacman命令:

sudo pacman -S lm_sensors

设置和配置

现在,已安装lm-sensors,是时候运行sensors-detect命令来检测并生成内核模块列表了。

sudo lm-sensors

现在,应该开始进行硬件探测。
因此,对所有问题按[Enter]键以创建/etc/sensors3.conf文件。
该文件用于加载Linux内核模块并在启动时自动启动服务。
使用cat命令显示/etc/sensors3.conf:

cat /etc/sensors3.conf

输出示例:

# libsensors configuration file
# ----------------------------
#
# This default configuration file only includes statements which do not
# differ from one mainboard to the next. Only label, compute and set
# statements for internal voltage and temperature sensors are included.
#
# In general, local changes should not be added to this file, but rather
# placed in custom configuration files located in /etc/sensors.d. This
# approach makes further updates much easier.
#
# Such custom configuration files for specific mainboards can be found in
# "configs" directory of lm-sensors package.
#
# Please contribute back a configuration of your board so other users with
# the same hardware won't need to recreate it again and again.

chip "lm78-*" "lm79-*" "lm80-*" "lm96080-*"

    label temp1 "M/B Temp"

chip "w83792d-*"

    label in0 "VcoreA"
    label in1 "VcoreB"
    label in6 "+5V"
    label in7 "5VSB"
    label in8 "Vbat"

    set in6_min  5.0 * 0.90
    set in6_max  5.0 * 1.10
    set in7_min  5.0 * 0.90
    set in7_max  5.0 * 1.10
    set in8_min  3.0 * 0.90
    set in8_max  3.0 * 1.10

chip "w83793-*"

显示风扇速度和其他信息

类型:

sensors

您可以使用grep命令过滤出数据:

sensors | grep -i fan

我们的最后一个示例包括watch命令,该命令在屏幕上显示风扇速度:

watch -n1 -d sensors
watch -n1 -d 'sensors | grep fan'
watch -n1 -d 'sensors | egrep "fan|temp" | grep -v "0.0"'

图形显示

重复运行传感器命令,并在屏幕上显示信息

尝试安装psensor

sudo apt install psensor # Debian/Ubuntu
sudo zypper in psensor # Suse/OpenSUSE
sudo pacman -S psensor # Arch Linux
sudo yum install xsensors # CentOS/RHEL (use xsensors instead of psensor)

运行:

psensor
## centos/rhel user run ##
xsensors

在Linux中使用GUI工具显示传感器数据,例如风扇速度,GPU/CPU温度等

xsenors正在显示wifi,gpu,cpu,风扇,电池和其他信息