題 如何在linux下監控CPU溫度?


如何使用Linux監視和顯示CPU溫度?


129
2017-08-19 00:08


起源


很高興看到這麼短,快速和準確的問題得到如此多的回應:-) - Jan Koester


答案:


正如其他人所說,你需要 LM-傳感器 包。我想我應該提一下,除了安裝包之外,你應該運行 傳感器偵測 用於標識需要加載的內核模塊的命令。

如果您還沒有這樣做,請手動運行一次並檢查它是否檢測到計算機上的任何傳感器。

$ sudo sensors-detect 
# sensors-detect revision 5249 (2008-05-11 22:56:25 +0200)

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.

We can start with probing for (PCI) I2C or SMBus adapters.
Do you want to probe now? (YES/no): 
Probing for PCI bus adapters...
Use driver `i2c-i801' for device 0000:00:1f.3: Intel 82801G ICH7

We will now try to load each adapter module in turn.
Module `i2c-i801' already loaded.
If you have undetectable or unsupported I2C/SMBus adapters, you can have
them scanned by manually loading the modules before running this script.

We are now going to do the I2C/SMBus adapter probings. Some chips may
be double detected; we choose the one with the highest confidence
value in that case.
If you found that the adapter hung after probing a certain address,
you can specify that address to remain unprobed.

Next adapter: SMBus I801 adapter at 10c0 (i2c-0)
Do you want to scan it? (YES/no/selectively): 
Client found at address 0x50
Probing for `Analog Devices ADM1033'...                     No
Probing for `Analog Devices ADM1034'...                     No
Probing for `SPD EEPROM'...                                 Yes
    (confidence 8, not a hardware monitoring chip)
Probing for `EDID EEPROM'...                                No
Client found at address 0x52
Probing for `Analog Devices ADM1033'...                     No
Probing for `Analog Devices ADM1034'...                     No
Probing for `SPD EEPROM'...                                 Yes
    (confidence 8, not a hardware monitoring chip)
Probing for `EDID EEPROM'...                                No

Some chips are also 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 LM78-J' 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
Probing for `IPMI BMC KCS' at 0xca0...                      No
Probing for `IPMI BMC SMIC' at 0xca8...                     No

Some Super I/O chips may also contain 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'...                   No
Trying family `SMSC'...                                     Yes
Found unknown chip with ID 0x2803
Probing for Super-I/O at 0x4e/0x4f
Trying family `National Semiconductor'...                   No
Trying family `SMSC'...                                     No
Trying family `VIA/Winbond/Fintek'...                       No
Trying family `ITE'...                                      No

Some south bridges, CPUs or memory controllers may also contain
embedded sensors. Do you want to scan for them? (YES/no): 
Silicon Integrated Systems SIS5595...                       No
VIA VT82C686 Integrated Sensors...                          No
VIA VT8231 Integrated Sensors...                            No
AMD K8 thermal sensors...                                   No
AMD K10 thermal sensors...                                  No
Intel Core family thermal sensor...                         Success!
    (driver `coretemp')
Intel AMB FB-DIMM thermal sensor...                         No

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

Driver `coretemp' (should be inserted):
  Detects correctly:
  * Chip `Intel Core family thermal sensor' (confidence: 9)

I will now generate the commands needed to load the required modules.
Just press ENTER to continue: 

To load everything that is needed, add this to /etc/modules:

#----cut here----
# Chip drivers
coretemp
#----cut here----

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

如果你很幸運,你的筆記本電腦將支持一系列傳感器。如果沒有,您仍然可以為CPU找到一組基本傳感器:

$ sensors
acpitz-virtual-0
Adapter: Virtual device
temp1:       +40.5°C  (crit = +105.0°C)                  

coretemp-isa-0000
Adapter: ISA adapter
Core 0:      +35.0°C  (crit = +100.0°C)                  

coretemp-isa-0001
Adapter: ISA adapter
Core 1:      +40.0°C  (crit = +100.0°C)                  

120
2017-08-19 00:30



如果你想在屏幕上使用它,我喜歡使用gmrellm,它使用lm-sensors進行檢測。 - Col
如果你想在屏幕上顯示並且不想使用gkrellm,你也可以使用conky。 - geek
如果你使用的是redhat,你的軟件包可能被稱為lm_sensors(下劃線而不是常規破折號) - msb
Arch上也是如此,它是 lm_sensors。 - bfontaine
只是想補充說,我第一次做傳感器檢測後總是要重新啟動。 - Chuck Claunch


使用'傳感器'(來自lm-sensors)和'watch'(來自procps pkg),您可以通過以下方式在命令行上實時監控傳感器數據:

watch -n 1 -d sensors

這將每1秒顯示一次傳感器並突出顯示與前一秒的差異。

Every 1.0s: /usr/bin/sensors

...
temp1:       +55C  (high =   +50C, hyst =   +45C)   sensor = thermistor   ALARM
temp2:     +35.0C  (high =   +80C, hyst =   +75C)   sensor = thermistor
temp3:     +35.0C  (high =   +80C, hyst =   +75C)   sensor = thermistor

76
2018-01-26 20:52



為什麼不通過華氏度語法? - Jacob Jan Tuinstra
很簡單,在上面的sensors命令中添加'-f'選項 - johnnyB
值得注意的是,您需要安裝lm-sensors軟件包才能實現此功能。 - William Everett


LM-傳感器

Lm-sensors是一種硬件健康   Linux的監控包。它   允許您從中訪問信息   溫度,電壓和風扇速度   傳感器。它適用於大多數新版本   系統。   該軟件包包含幫助程序   你設置和讀取數據   LM-傳感器。

要安裝使用:

# sudo apt-get install lm-sensors sensors-applet

使用:

# sensors-detect
...
# sensors
V1.5:      +2.467 V  (min =  +1.42 V, max =  +1.58 V)   ALARM
VCore:     +1.479 V  (min =  +1.48 V, max =  +1.63 V)   ALARM
V3.3:      +3.373 V  (min =  +3.13 V, max =  +3.47 V)
V5:       +5.000 V  (min =  +4.74 V, max =  +5.26 V)
V12:      +11.734 V  (min = +11.38 V, max = +12.62 V)
CPU_Fan:   2299 RPM  (min = 4000 RPM)                     ALARM
fan2:         0 RPM  (min =    0 RPM)
fan3:      1057 RPM  (min =    0 RPM)
fan4:         0 RPM  (min =    0 RPM)
CPU:      +41.50°C  (low  =   +10°C, high =   +50°C)
Board:    +35.25°C  (low  =   +10°C, high =   +35°C)
Remote:   +35.50°C  (low  =   +10°C, high =   +35°C)     ALARM
CPU_PWM:   144
Fan2_PWM:  112
Fan3_PWM:  112
vid:      +1.550 V  (VRM Version 9.0)

或將小程序添加到任務欄。

enter image description here


您也可以嘗試使用computertemp applet。

Ubuntu包 

主頁

電腦溫度監控器是一個   GNOME桌面的小程序   這顯示了你的溫度   計算機CPU和磁盤在屏幕上。

它還允許您記錄溫度   到一個文件。您可以將警報設置為   溫度是時通知你   到達。可以添加幾個監視器   到面板監控不同   傳感器。它的設計看起來像   CPU頻率Gnome applet,所以他們   在面板上相互匹配。

要安裝使用:

sudo apt-get install computertemp

然後添加到任務欄

enter image description here


21
2017-08-19 00:10





我有戴爾服務器(Poweredge R420)正在運行 Fedora的 / 紅帽Linux。我安裝了lm_sensors,但是 sensors 給了我一條消息說內核驅動程序沒有加載。我使用sensor-detect來找出我需要的傳感器,結果發現我需要IPMI。

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

Driver `ipmisensors':
  * ISA bus, address 0xca8
    Chip `IPMI BMC KCS' (confidence: 8)

Warning: the required module ipmisensors is not currently installed
on your system. If it is built into the kernel then it's OK.
Otherwise, check http://www.lm-sensors.org/wiki/Devices for
driver availability.

我檢查了頁面,建議我使用ipmitool。我安裝了它,但它仍然無法正常工作:

$ ipmitool sensor
Could not open device at /dev/ipmi0 or /dev/ipmi/0 or /dev/ipmidev/0: No such file or directory
Get Device ID command failed
Unable to open SDR for reading

經過一些研究後,我遇到了這個頁面: http://osdir.com/ml/hardware.ipmitool.devel/2008-02/msg00012.html

他們的腳本ipmimod.sh為我開箱即用:

#!/bin/bash

#IPMI kernel module installer for Redhat-style machines
#dranch-3r7Miqu9kMnR7s880joybQ@xxxxxxxxxxxxxxxx

#07/26/06 - use absolute paths for modprobe
#05/01/06 - orig version

/sbin/modprobe ipmi_devintf

maj=`cat /proc/devices | awk '/ipmidev/{print $1}'`
echo $maj
if [ -c /dev/ipmi0 ]
then
   rm -f /dev/ipmi0
   /bin/mknod /dev/ipmi0 c $maj 0
else
   /bin/mknod /dev/ipmi0 c $maj 0
fi

IPMI_DRIVERS="ipmi_si ipmi_si_drv ipmi_kcs_drv"
for driver in $IPMI_DRIVERS; do
  find /lib/modules/`uname -r`/kernel/drivers/char/ipmi | grep $driver > /dev/null
  RETURN_VALUE=$?
  if [ $RETURN_VALUE -eq 0 ] ; then
    #Here are specific memory locations for Supermicro AOC-type IPMI cards
    /sbin/modprobe $driver type=kcs ports=0xca8 regspacings=4
    break
  fi
done

運行之後,我終於能夠看到CPU溫度:

$ ipmitool sensor | grep Temp
Inlet Temp       | 24.000     | degrees C  | ok    | na        | -7.000    | 3.000     | 42.000    | 47.000    | na
Temp             | na         | degrees C  | na    | na        | 3.000     | 8.000     | 77.000    | 83.000    | na
Temp             | na         | degrees C  | na    | na        | 3.000     | 8.000     | 77.000    | 83.000    | na

我希望這可以幫助戴爾服務器難以獲得溫度的任何人。


9
2017-09-20 18:07





Linux允許您訪問溫度信息傳感器。它適用於RH6.2x64。

此驅動程序包含使用lm-sensors的讀取支持:

類型

modprobe coretemp
sensors

6
2017-07-18 13:43





我發現了其他帶gui的軟件來監控溫度。 該軟件的名稱是:Psensor: https://wpitchoune.net/psensor/

從互聯網上看文章: https://www.tecmint.com/psensor-monitors-hardware-temperature-in-linux/

要在Ubuntu / Mint上安裝,請在終端上運行以下命令:

sudo apt install psensor

要運行該應用程序,只需運行以下命令:

sudo psensor

謝謝。


3
2017-09-03 04:36



要配置傳感器,請運行此命令並為所有問題鍵入yes: sudo sensors-detect - Wellington1993


ACPI

值得一提的是 acpi 命令,

acpi -t   # or -V for all

-t | --thermal:顯示熱量信息

apt-cache show acpi

說明恩: 顯示有​​關ACPI設備的信息    試圖複製的功能 “舊” apm命令    ACPI系統,包括電池和電池 熱量信息
   不支持    ACPI掛起,僅顯示有關ACPI設備的信息。

主頁: http://sourceforge.net/projects/acpiclient

在類似Ubuntu的系統上,你可以安裝它

sudo apt-get install acpi

注意: 你可以監測溫度 watch -n 1 -d acpi -V 或者你可以開始解析它的輸出(或者 sensors 一)腳本(有或沒有 date 命令),添加顏色,將輸出記錄到文件中...

while [[ 1 ]] ; do acpi -t | awk '{printf ("%2.2f ",$4)}'; date; sleep 1 ; done 


2
2018-05-25 10:19