在 CentOS 上安裝 CPU 溫度監控軟體(lm_sensors)
阿新 • • 發佈:2018-12-31
出處:http://liang.eu/servers/install-lm_sensors-on-centos-5-4-64bit
前段時間新裝了一臺伺服器,系統是 CentOS 5.4 x64,託管在天通苑的一個機房裡,上次去裝機器的時候注意到他們機房有時候不開空調,機房內溫度很高,所以有點不放心,所以想裝一個 CPU 溫度監控軟體方便隨時檢視機器是否在正常溫度下工作。
查了些資料,基本都是 lm_sensors 的,網上說的都很簡單,看了幾遍後心中比較有數了,就開始動手。本以為會很順利,結果走了不少彎路,查了很多資料才最終安裝成功成。現在在這裡記下一些網上的文章都沒有提到的細節,正是這些細節讓我走了不少彎路。
先安裝 lm_sensors:
[[email protected] ~]# yum install lm_sensors
安裝完畢後執行 sensors-detect:
[[email protected] ~]# /usr/sbin/sensors-detect
然後一路回車,到了最後的時候出現了這個:
Do you want to overwrite /etc/sysconfig/lm_sensors? (YES/no):
Starting lm_sensors: No sensors found!
Make sure you loaded all the kernel drivers you need.
Try sensors-detect to find out which these are.
[FAILED]
網上查了下,很多的朋友也都碰到這個問題,但都不知道怎麼解決,沒有經驗可以借鑑,只好自力更生了。
最後google到一個線索:使用最新版的 sensors-detect。於是下載最新版的 sensors-detect:
[[email protected] ~]# wget http://dl.lm-sensors.org/lm-sensors/files/sensors-detect
[[email protected] ~]# chmod u+x sensors-detect
[[email protected] ~]# ./sensors-detect
…
這次安裝還是沒成功,但是,非常重要的是,這個新版的sensors-detect給出了失敗的原因
Warning: the required module coretemp 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.
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.
No modules to load, skipping modules configuration.
[[email protected] ~]# wget http://www.cs.vsu.ru/~raskhozhev/files/dkms-coretemp-1.00-1.noarch.rpm
[[email protected] ~]# rpm -i dkms-coretemp-1.00-1.noarch.rpm
提示需要這個rpm包依賴 dkms 包,那就裝吧:
[[email protected] ~]# yum install dkms
然後繼續安裝:
[[email protected] ~]# rpm -i dkms-coretemp-1.00-1.noarch.rpm
成功了,接著重新開始 sensors-detect:
[[email protected] ~]# /usr/sbin/sensors-detect
…
Do you want to overwrite /etc/sysconfig/lm_sensors? (YES/no):
Starting lm_sensors: [ OK ]
終於看到綠色OK,啟動 lm_sensors:
[[email protected] ~]# sensors
coretemp-isa-0000
Adapter: ISA adapter
Core 0: +34°C (high = +100°C)
coretemp-isa-0001
Adapter: ISA adapter
Core 1: +34°C (high = +100°C)
成功!感謝國家!
總結:
- Linux Kernel 2.6.22 以上才自帶 coretemp,CentOS 5.4 使用的是 Kernel 2.6.18,所以沒有自帶這個模組,需要自己patch或者安裝第三方做好的rpm
- lm_sensors 需要 coretemp 模組,否則無法找到感測器。
- 上面的錯誤資訊也提到缺少 ipmisensors 模組(如果裝上這個模組,lm_sensors 好像還可以檢視風扇轉速、CPU電壓等其他資訊,但我不需要這些,所以沒裝),但如果不裝,也能檢視CPU溫度