linux lm_sensors传感器读取

2023-12-15 10:43:37

lm_sensors介绍

lm_sensors是一个用于监测硬件传感器的工具,它可以用于获取计算机系统中各种硬件组件的温度、电压、风扇转速等信息。lm_sensors的作用主要包括以下几个方面:

  1. 监测硬件温度:lm_sensors可以监测CPU、GPU、主板、硬盘等硬件组件的温度,并在温度超过预设阈值时触发警报。这有助于用户及时发现硬件故障或过热问题,避免硬件损坏或系统崩溃。

  2. 监测电压:lm_sensors可以监测系统中各种电压的变化,如CPU核心电压、+3.3V电压、+5V电压、+12V电压等。这有助于用户了解系统的电源稳定性,及时发现电源故障或电压异常问题。

  3. 监测风扇转速:lm_sensors可以监测系统中各种风扇的转速,如CPU风扇、机箱风扇、显卡风扇等。这有助于用户了解系统的散热情况,及时发现风扇故障或风扇转速异常问题。

  4. 自定义传感器配置:lm_sensors允许用户自定义传感器的配置,包括传感器的名称、类型、临界值等信息。用户可以根据自己的需求编辑配置文件,定制自己的传感器监测方案。

安装方法

  • RHEL/CentOS,Fedora:

    sudo yum install lm_sensors
    
  • Debian, Ubuntu:

    sudo apt install lm-sensors

?命令使用

检测系统寄存器sensors-detect

bsp-server@bsp:/sys/class/thermal$ sudo sensors-detect
# sensors-detect version 3.6.0
# System: HPE ProLiant DL380 Gen10
# Kernel: 6.2.0-37-generic x86_64
# Processor: Intel(R) Xeon(R) Silver 4114 CPU @ 2.20GHz (6/85/4)

This program will help you determine which kernel modules you need
to load to use lm_sensors most effectively. It is generally safe
and recommended to accept the default answers to all questions,
unless you know what you're doing.

Some south bridges, CPUs or memory controllers contain embedded sensors.
Do you want to scan for them? This is totally safe. (YES/no): 
Silicon Integrated Systems SIS5595...                       No
VIA VT82C686 Integrated Sensors...                          No
VIA VT8231 Integrated Sensors...                            No
AMD K8 thermal sensors...                                   No
AMD Family 10h thermal sensors...                           No
AMD Family 11h thermal sensors...                           No
AMD Family 12h and 14h thermal sensors...                   No
AMD Family 15h thermal sensors...                           No
AMD Family 16h thermal sensors...                           No
AMD Family 17h thermal sensors...                           No
AMD Family 15h power sensors...                             No
AMD Family 16h power sensors...                             No
Hygon Family 18h thermal sensors...                         No
Intel digital thermal sensor...                             Success!
    (driver `coretemp')
Intel AMB FB-DIMM thermal sensor...                         No
Intel 5500/5520/X58 thermal sensor...                       No
VIA C7 thermal sensor...                                    No
VIA Nano thermal sensor...                                  No

Some Super I/O chips contain embedded sensors. We have to write to
standard I/O ports to probe them. This is usually safe.
Do you want to scan for Super I/O sensors? (YES/no): 
Probing for Super-I/O at 0x2e/0x2f
Trying family `National Semiconductor/ITE'...               Yes
Found unknown chip with ID 0x0401
Probing for Super-I/O at 0x4e/0x4f
Trying family `National Semiconductor/ITE'...               No
Trying family `SMSC'...                                     No
Trying family `VIA/Winbond/Nuvoton/Fintek'...               No
Trying family `ITE'...                                      No

Some systems (mainly servers) implement IPMI, a set of common interfaces
through which system health data may be retrieved, amongst other things.
We first try to get the information from SMBIOS. If we don't find it
there, we have to read from arbitrary I/O ports to probe for such
interfaces. This is normally safe. Do you want to scan for IPMI
interfaces? (YES/no): 
Found `IPMI BMC KCS' at 0xca2...                            Success!
    (confidence 8, driver `to-be-written')

Some hardware monitoring chips are accessible through the ISA I/O ports.
We have to write to arbitrary I/O ports to probe them. This is usually
safe though. Yes, you do have ISA I/O ports even if you do not have any
ISA slots! Do you want to scan the ISA I/O ports? (YES/no): 
Probing for `National Semiconductor LM78' at 0x290...       No
Probing for `National Semiconductor LM79' at 0x290...       No
Probing for `Winbond W83781D' at 0x290...                   No
Probing for `Winbond W83782D' at 0x290...                   No

Lastly, we can probe the I2C/SMBus adapters for connected hardware
monitoring devices. This is the most risky part, and while it works
reasonably well on most systems, it has been reported to cause trouble
on some systems.
Do you want to probe the I2C/SMBus adapters now? (YES/no): 
Sorry, no supported PCI bus adapters found.

Next adapter: mga i2c (i2c-0)
Do you want to scan it? (yes/NO/selectively): 


Now follows a summary of the probes I have just done.
Just press ENTER to continue: 

Driver `coretemp':
  * Chip `Intel digital thermal sensor' (confidence: 9)

Driver `to-be-written':
  * ISA bus, address 0xca2
    Chip `IPMI BMC KCS' (confidence: 8)

Note: there is no driver for IPMI BMC KCS yet.
Check https://hwmon.wiki.kernel.org/device_support_status for updates.

To load everything that is needed, add this to /etc/modules:
#----cut here----
# Chip drivers
coretemp
#----cut here----
If you have some drivers built into your kernel, the list above will
contain too many modules. Skip the appropriate ones!

Do you want to add these lines automatically to /etc/modules? (yes/NO)

获取传感器值

bsp-server@bsp:/sys/class/thermal$ sensors -A
coretemp-isa-0000
Package id 0:  +35.0°C  (high = +79.0°C, crit = +89.0°C)
Core 0:        +34.0°C  (high = +79.0°C, crit = +89.0°C)
Core 1:        +34.0°C  (high = +79.0°C, crit = +89.0°C)
Core 2:        +32.0°C  (high = +79.0°C, crit = +89.0°C)
Core 3:        +33.0°C  (high = +79.0°C, crit = +89.0°C)
Core 4:        +34.0°C  (high = +79.0°C, crit = +89.0°C)
Core 8:        +34.0°C  (high = +79.0°C, crit = +89.0°C)
Core 9:        +32.0°C  (high = +79.0°C, crit = +89.0°C)
Core 10:       +33.0°C  (high = +79.0°C, crit = +89.0°C)
Core 11:       +32.0°C  (high = +79.0°C, crit = +89.0°C)
Core 12:       +34.0°C  (high = +79.0°C, crit = +89.0°C)

pch_lewisburg-virtual-0
temp1:        +41.0°C  

coretemp-isa-0001
Package id 1:  +51.0°C  (high = +79.0°C, crit = +89.0°C)
Core 0:        +44.0°C  (high = +79.0°C, crit = +89.0°C)
Core 1:        +45.0°C  (high = +79.0°C, crit = +89.0°C)
Core 2:        +44.0°C  (high = +79.0°C, crit = +89.0°C)
Core 3:        +44.0°C  (high = +79.0°C, crit = +89.0°C)
Core 4:        +45.0°C  (high = +79.0°C, crit = +89.0°C)
Core 8:        +45.0°C  (high = +79.0°C, crit = +89.0°C)
Core 9:        +45.0°C  (high = +79.0°C, crit = +89.0°C)
Core 10:       +45.0°C  (high = +79.0°C, crit = +89.0°C)
Core 11:       +50.0°C  (high = +79.0°C, crit = +89.0°C)
Core 12:       +45.0°C  (high = +79.0°C, crit = +89.0°C)

power_meter-acpi-0
power1:      120.00 W  (interval = 300.00 s)

文章来源:https://blog.csdn.net/weixin_38452632/article/details/135009770
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。