在我们服务器日常维护中,我们可能会关心服务器CPU的温度,如何在Linux系统中快速查看CPU温度呢?lm_sensors提供了一套方案,可以自动侦测主板传感器的型号和读取方式,可以在命令行模式下快速安装运行。这样我们就可以把CPU温度纳入到日常的监控中去了。
在CentOS系统中安装使用实例如下:
#yum install -y lm_sensors
然后运行sensors-detect来探测传感器类型,此命令会给出一些问题,一律回答Yes即可:
[root@cacti ~]# sensors-detect
# sensors-detect revision 1.1
# System: LENOVO 4286AF2 (laptop)
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): yes
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): y
Probing for Super-I/O at 0x2e/0x2f
Trying family `National Semiconductor'... No
Trying family `SMSC'... No
Trying family `VIA/Winbond/Nuvoton/Fintek'... No
Trying family `ITE'... No
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 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): y
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): y
Found unknown SMBus adapter 8086:1c22 at 0000:00:1f.3.
Sorry, no supported PCI bus adapters found.
Module i2c-dev loaded successfully.
Next adapter: i915 gmbus ssc (i2c-0)
Do you want to scan it? (YES/no/selectively): y
Next adapter: i915 gmbus vga (i2c-1)
Do you want to scan it? (YES/no/selectively): y
Next adapter: i915 gmbus panel (i2c-2)
Do you want to scan it? (YES/no/selectively): y
Client found at address 0x50
Probing for `Analog Devices ADM1033'... No
Probing for `Analog Devices ADM1034'... No
Probing for `SPD EEPROM'... No
Probing for `EDID EEPROM'... Yes
(confidence 8, not a hardware monitoring chip)
Next adapter: i915 gmbus dpc (i2c-3)
Do you want to scan it? (YES/no/selectively): y
Next adapter: i915 gmbus dpb (i2c-4)
Do you want to scan it? (YES/no/selectively): y
Next adapter: i915 gmbus dpd (i2c-5)
Do you want to scan it? (YES/no/selectively): y
Next adapter: DPDDC-B (i2c-6)
Do you want to scan it? (YES/no/selectively): y
Next adapter: DPDDC-C (i2c-7)
Do you want to scan it? (YES/no/selectively): y
Next adapter: DPDDC-D (i2c-8)
Do you want to scan it? (YES/no/selectively): y
Next adapter: SMBus I801 adapter at efa0 (i2c-9)
Do you want to scan it? (YES/no/selectively): y
Client found at address 0x2b
Probing for `National Semiconductor LM78'... No
Probing for `National Semiconductor LM79'... No
Probing for `National Semiconductor LM80'... No
Probing for `Winbond W83781D'... No
Probing for `Winbond W83782D'... No
Probing for `Winbond W83627HF'... No
Probing for `Winbond W83627EHF'... No
Probing for `Winbond W83627DHG/W83667HG/W83677HG'... No
Probing for `Asus AS99127F (rev.1)'... No
Probing for `Asus AS99127F (rev.2)'... No
Probing for `Asus ASB100 Bach'... No
Probing for `Analog Devices ADM1021'... No
Probing for `Analog Devices ADM1021A/ADM1023'... No
Probing for `Maxim MAX1617'... No
Probing for `Maxim MAX1617A'... No
Probing for `Maxim MAX1668'... No
Probing for `Maxim MAX1805'... No
Probing for `Maxim MAX1989'... No
Probing for `Maxim MAX6655/MAX6656'... No
Probing for `TI THMC10'... No
Probing for `National Semiconductor LM84'... No
Probing for `Genesys Logic GL523SM'... No
Probing for `Onsemi MC1066'... No
Probing for `Maxim MAX1618'... No
Probing for `Maxim MAX1619'... No
Probing for `National Semiconductor LM82/LM83'... No
Probing for `Maxim MAX6654/MAX6690'... No
Probing for `Maxim MAX6680/MAX6681'... No
Probing for `National Semiconductor LM95231'... No
Probing for `National Semiconductor LM95241'... No
Probing for `Analog Devices ADM1029'... No
Probing for `ITE IT8712F'... No
Client found at address 0x50
Probing for `Analog Devices ADM1033'... No
Probing for `Analog Devices ADM1034'... No
Probing for `SPD EEPROM'... No
Probing for `EDID EEPROM'... No
Client found at address 0x5c
Probing for `Analog Devices ADT7462'... No
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): y
Starting lm_sensors: loading module coretemp [确定]
Unloading i2c-dev... OK
最后运行sensors命令来查看CPU温度:
[root@cacti ~]# sensors
acpitz-virtual-0
Adapter: Virtual device
temp1: +32.0°C (crit = +99.0°C)
thinkpad-isa-0000
Adapter: ISA adapter
fan1: 1974 RPM
coretemp-isa-0000
Adapter: ISA adapter
Physical id 0: +40.0°C (high = +86.0°C, crit = +100.0°C)
Core 0: +40.0°C (high = +86.0°C, crit = +100.0°C)
Core 1: +38.0°C (high = +86.0°C, crit = +100.0°C)
我们还可以将lm_sensors服务设置为自动启动,以便自动加载相关模块:
[root@cacti ~]# chkconfig lm_sensors on
[root@cacti ~]# service lm_sensors start
Starting lm_sensors: loading module coretemp [确定]
lm_sensors项目官方网站:
http://lm-sensors.org/