Skip to content Skip to main navigation Skip to footer

Linux/Centos:如何快速的检测CPU的温度

cpu_temp于linux系统管理员,需要知道如何能更快速的来检测服务器中cpu的温度,那如何才能检测到cpu的温度信息呢?下面本文将会介绍一个工具叫lm_sensor来获取cpu的温度:
首先我们需要检测下lm_sensors这个软件包是否被安装。

[root@devops ~]# rpm -qa | grep lm_sensors  #通过查询,当前系统没有安装该工具
 

接下来我们就通过yum来安装:

[root@devops ~]# yum install lm_sensors
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
epel/metalink                                            | 5.8 kB     00:00
* base: mirrors.btte.net
* epel: ftp.cuhk.edu.hk
* extras: mirrors.tuna.tsinghua.edu.cn
* updates: mirrors.btte.net
base                                                     | 3.7 kB     00:00
epel                                                     | 4.4 kB     00:00
epel/primary_db                                          | 6.2 MB     00:03
extras                                                   | 3.4 kB     00:00
updates                                                  | 3.4 kB     00:00
updates/primary_db                                       | 3.7 MB     00:01
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package lm_sensors.x86_64 0:3.1.1-17.el6 will be installed
--> Processing Dependency: lm_sensors-libs(x86-64) = 3.1.1-17.el6 for package:
lm_sensors-3.1.1-17.el6.x86_64
--> Processing Dependency: /usr/sbin/dmidecode for package: lm_sensors-3.1.1-17.el6.x86_64
--> Processing Dependency: libsensors.so.4()(64bit) for package: lm_sensors-3.1.1-17.el6.x86_64
--> Running transaction check
---> Package dmidecode.x86_64 1:2.12-5.el6_5 will be installed
---> Package lm_sensors-libs.x86_64 0:3.1.1-17.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=====================================================
Package               Arch         Version                 Repository     Size
=====================================================
Installing:
lm_sensors            x86_64       3.1.1-17.el6            base          123 k
Installing for dependencies:
dmidecode             x86_64       1:2.12-5.el6_5          updates        73 k
lm_sensors-libs       x86_64       3.1.1-17.el6            base           38 k
Transaction Summary
=====================================================
Install       3 Package(s)
Total download size: 235 k
Installed size: 605 k
Is this ok [y/N]:
...
Complete!
 

安装lm_sensors之后,我们需要使用sensors-detect命令来加载所有需要的内核模块,这样才能检测cpu的温度,输入下面的命令:

[root@devops ~]# sh -c "yes|sensors-detect"
# sensors-detect revision 1.1
# System: VMware, Inc. VMware Virtual Platform
# Board: Intel Corporation 440BX Desktop Reference Platform
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 11h thermal sensors...                           No
Intel digital thermal sensor...                             Success!
(driver `coretemp')
Intel AMB FB-DIMM thermal sensor...                         No
VIA C7 thermal and voltage sensors...                       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'...                   Yes
Found unknown chip with ID 0x0f00
Probing for Super-I/O at 0x4e/0x4f
Trying family `National Semiconductor'...                   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): Probing for `IPMI BMC KCS' at 0xca0...                      No
Probing for `IPMI BMC SMIC' at 0xca8...                     No
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): Using driver
`i2c-piix4' for device 0000:00:07.3: Intel 82371AB PIIX4
ACPI
Module i2c-dev loaded successfully.
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)
Do you want to overwrite /etc/sysconfig/lm_sensors? (YES/no): Starting lm_sensors:
loading module coretemp [确定]
Unloading i2c-dev... OK
 

所有必需的内核模块加载完毕后,我们就可以使用sensor命令来检测当前主机的cpu的温度了:

[root@devops ~]# sensors
coretemp-isa-0000
Adapter: ISA adapter
ERROR: Can't get value of subfeature temp1_input: Can't read
Physical id 0:  +0.0°C  (high = +100.0°C, crit = +100.0°C)
ERROR: Can't get value of subfeature temp2_input: Can't read
Core 0:         +0.0°C  (high = +100.0°C, crit = +100.0°C)
 
0 Comments

There are no comments yet

Leave a comment

Your email address will not be published.