システムの温度変化を、手っ取り早くグラフ化して監視する。
まず、LM75など温度センサーICとのインターフェース・デーモンをインストールする。
[root@wslnx-111 ~]# yum install lm_sensors
〜 (中略) インストールされる画面表示 〜
[root@wslnx-111 ~]# sensors-detect
〜 (中略) 自動コンフィグ、質問は基本的にデフォルトのYESなどで 〜
user@localhost:~$ sudo apt-get install lm-sensors
Password:
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています
Reading state information... 完了
提案パッケージ:
sensord read-edid
以下のパッケージが新たにインストールされます:
lm-sensors
アップグレード: 0 個、新規インストール: 1 個、削除: 0 個、保留: 0 個。
501kB のアーカイブを取得する必要があります。
展開後に追加で 1544kB のディスク容量が消費されます。
取得:1 http://jp.archive.ubuntu.com feisty/main lm-sensors 1:2.10.1-2ubuntu2 [501kB]
501kB を 0s で取得しました (1355kB/s)
未選択パッケージ lm-sensors を選択しています。
(データベースを読み込んでいます ... 現在 107572 個のファイルとディレクトリがインストールされています。)
(.../lm-sensors_1%3a2.10.1-2ubuntu2_i386.deb から) lm-sensors を展開しています...
lm-sensors (2.10.1-2ubuntu2) を設定しています ...
Creating config file /etc/sensors.conf with new version
user@localhost:~$ sudo sensors-detect
Password:
# sensors-detect revision 4171 (2006-09-24 03:37:01 -0700)
〜 中略 〜
Now follows a summary of the probes I have just done.
Just press ENTER to continue:
Driver `to-be-written' (should be inserted):
Detects correctly:
* Bus `SMBus I801 adapter at 5000'
Busdriver `i2c-i801', I2C address 0x2f
Chip `Fintek custom power control IC' (confidence: 7)
Driver `eeprom' (should be inserted):
Detects correctly:
* Bus `SMBus I801 adapter at 5000'
Busdriver `i2c-i801', I2C address 0x50
Chip `SPD EEPROM' (confidence: 8)
* Bus `SMBus I801 adapter at 5000'
Busdriver `i2c-i801', I2C address 0x52
Chip `SPD EEPROM' (confidence: 8)
EEPROMs are *NOT* sensors! They are data storage chips commonly
found on memory modules (SPD), in monitors (EDID), or in some
laptops, for example.
Driver `w83627hf' (should be inserted):
Detects correctly:
* ISA bus address 0x0290 (Busdriver `i2c-isa')
Chip `Winbond W83627THF Super IO Sensors' (confidence: 9)
I will now generate the commands needed to load the required modules.
Just press ENTER to continue:
To make the sensors modules behave correctly, add these lines to
/etc/modules:
#----cut here----
# I2C adapter drivers
i2c-i801
# Chip drivers
# no driver for Fintek custom power control IC yet
eeprom
w83627hf
#----cut here----
Do you want to add these lines to /etc/modules automatically? (yes/NO)y
user@localhost:~$
sensors-detect のコンフィグ中の表示で /etc/rc.local と /etc/modprobe.conf に追加すべき記述が出てくるので、それが追加されているか各設定ファイルを開いてチェックする。(追加されていない場合は、手動追加する)
… (前略) …
/modprobe -r --ignore-remove snd-hda-intel
# I2C module options
alias char-major-89 i2c-dev
… (前略) …
touch /var/lock/subsys/local
# I2C adapter drivers
modprobe i2c-i801
modprobe i2c-isa
# I2C chip drivers
modprobe eeprom
modprobe w83627hf
# sleep 2 # optional
/usr/bin/sensors -s # recommended
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
fuse
lp
# I2C adapter drivers
i2c-i801
# Chip drivers
eeprom
w83627hf
なお、各値名前や値の最大・最小などを決める定義ファイルは /etc/sensors.conf に書かれているので、マシンのセンサー名の項目以下を適宜修正する。
… (前略) …
chip "w83627thf-*" "w83637hf-*"
label in0 "VCore"
label in1 "+12V"
label in2 "+3.3V"
label in3 "+5V"
label in4 "-12V"
label in7 "V5SB"
label in8 "VBat"
compute in1 ((28/10)+1)*@, @/((28/10)+1)
compute in3 ((34/51)+1)*@, @/((34/51)+1)
compute in4 (5.14*@)-14.91, (@+14.91)/5.14
compute in7 ((6.8/10)+1)*@ , @/((6.8/10)+1)
set in0_min 0.988 * 0.98 # Pentium M 750 Vccmax
set in0_max 1.356 * 1.00 # Pentium M 750 Vcclfm
set in1_min 12 * 0.95
set in1_max 12 * 1.05
set in2_min 3.3 * 0.95
set in2_max 3.3 * 1.05
set in3_min 5.0 * 0.95
set in3_max 5.0 * 1.05
set in4_min -12 * 1.10
set in4_max 0
set in7_min 5 * 0.95
set in7_max 5 * 1.05
set in8_min 3.0 * 0.80
set in8_max 3.0 * 1.20
# set sensor1 1
# set sensor2 2
# set sensor3 3435
label temp1 "M/B Temp"
label temp2 "CPU Temp"
ignore temp3
set temp1_over 45
set temp1_hyst 35
set temp2_over 60
set temp2_hyst 50
label fan1 "Case Fan"
label fan2 "CPU Fan"
ignore fan3
set fan1_div 8
set fan1_min 1400 # fanx_min must be written after fanx_div
set fan2_div 8
set fan2_min 2000
set beep_enable 0
Linuxを再起動するか、lm_sensorsデーモンを再起動して、モジュールがちゃんと読み込まれているか確認する。
※ 再起動しない場合、modprobeを手動で実行する必要がある場合もある。
[root@wslnx-111 ~]# /etc/rc.d/init.d/lm_sensors restart
lm_sensors を停止中: [ OK ]
lm_sensors を起動中: [ OK ]
[root@wslnx-111 ~]# lsmod | grep -e i2c
i2c_isa 5697 1 w83627hf
i2c_ec 5569 1 sbs
i2c_i801 8013 0
i2c_core 21697 5 w83627hf,eeprom,i2c_isa,i2c_ec,i2c_i801
[root@wslnx-111 ~]#
user@localhost:~$ sudo modprobe eeprom
user@localhost:~$ sudo modprobe w83627hf
user@localhost:~$ sudo /etc/init.d/lm-sensors restart
* Setting sensors limits... [ OK ]
user@localhost:~$ sudo lsmod | grep -e i2c
i2c_isa 6272 1 w83627hf
i2c_dev 8708 0
i2c_i801 9356 0
i2c_ec 6016 1 sbs
i2c_core 22656 6 w83627hf,i2c_isa,eeprom,i2c_dev,i2c_i801,i2c_ec
端末上で現在のセンサーの計測値を表示すると…
[root@wslnx-111 ~]# sensors
w83627thf-isa-0290 ← マシンのセンサー名(sensors.confではこのセンサー項目を編集すれば良い)
Adapter: ISA adapter
VCore: +1.00 V (min = +0.97 V, max = +1.35 V)
+12V: +12.10 V (min = +11.37 V, max = +12.59 V)
+3.3V: +3.38 V (min = +3.14 V, max = +3.47 V)
+5V: +4.96 V (min = +4.75 V, max = +5.25 V)
-12V: -5.62 V (min = -13.18 V, max = -0.02 V)
V5SB: +5.00 V (min = +4.76 V, max = +5.24 V)
VBat: +3.30 V (min = +2.40 V, max = +3.60 V)
Case Fan: 1577 RPM (min = 1394 RPM, div = 8) (beep)
CPU Fan: 2191 RPM (min = 2008 RPM, div = 8) (beep)
M/B Temp: +26°C (high = +45°C, hyst = +35°C) sensor = thermistor
CPU Temp: +41.0°C (high = +60°C, hyst = +50°C) sensor = diode (beep)
alarms:
beep_enable:
Sound alarm disabled
[root@wslnx-111 ~]#
ここまでの情報は @ITの次のトピックに書かれている
「CPUの温度やファンの回転数などをモニタするには」
http://www.atmarkit.co.jp/flinux/rensai/linuxtips/743hwmonitor.html
さらに、これを系時グラフ化する設定をMRTGで行う。
まずは MRTG のインストール。今回は、ネットの監視では無く、グラフ描画だけの機能を流用する。
[root@wslnx-111 ~]# yum install mrtg
設定ファイルをいじる
HtmlDir: /var/www/mrtg
ImageDir: /var/www/mrtg
LogDir: /var/lib/mrtg
ThreshDir: /var/lib/mrtg
Target[cputemp]: `/usr/bin/sensors | grep Temp | awk '{print $3}' | sed -e 's/+//' -e 's/[^0-9+\.].*//'`
MaxBytes[cputemp]: 100
Title[cputemp]: CPU and Motherboard Temperature by lm_sensors
PageTop[cputemp]: <h1>CPU and Motherboard Temperature</h1>
Options[cputemp]: growright,absolute,gauge,nopercent,noinfo
WithPeak[cputemp]: ymw
#unscaled[cputemp]: dwmy
YLegend[cputemp]: Temperature
ShortLegend[cputemp]: C
LegendI[cputemp]: M/B
LegendO[cputemp]: CPU
Legend1[cputemp]: M/B
Legend2[cputemp]: CPU
MRTGのマニュアルによれば、Target キーワードに外部コマンドを用いる場合は、計測された測定値を4行で出力させる必要性があるそうだ。
1行目:LegendI(数値)、2行目:LegendO(数値)、3行目:稼働時間(文字列)、4行目:対象名(文字列)。
MRTGを5分おきに起動させるために、cronの設定ファイルが次の様になっていることを確認する。
*/5 * * * * root LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok
グラフを見るには、Apacheが走っている場合は
http://localhost/mrtg/cputemp.html
そうでない場合は、直接ファイルを見に行く
file:///var/www/mrtg/cputemp.html
ここまでの情報は @ITの次のトピックに書かれている
「MRTGでCPUの温度変化をグラフ化するには」
http://www.atmarkit.co.jp/flinux/rensai/linuxtips/797mrtg2cpu.html
MRTG設定ファイルの記述方法は
http://www.mrtg.jp/
HDDの温度変化もグラフにしたい場合
hddtemp をインストール
[root@wslnx-111 ~]# yum install hddtemp
MRTG設定ファイル
Target[hddtemp]: `/usr/bin/sensors | grep "M/B Temp" | awk '{print $3}' | sed -e 's/+//' -e 's/[^0-9+\.].*//' && /usr/sbin/hddtemp /dev/sda | awk '{print $3}'|sed -e 's/[^0-9+\.].*//' && uptime && df | grep sda`
MaxBytes[hddtemp]: 100
Title[hddtemp]: HDD and Motherboard Temperature by lm_sensors and hddtemp
PageTop[hddtemp]: <h1>HDD and Motherboard Temperature</h1>
Options[hddtemp]: growright,absolute,gauge,nopercent
WithPeak[hddtemp]: ymw
#unscaled[hddtemp]: dwmy
YLegend[hddtemp]: Temperature
ShortLegend[hddtemp]: C
LegendI[hddtemp]: M/B
LegendO[hddtemp]: HDD
Legend1[hddtemp]: M/B
Legend2[hddtemp]: HDD
Legend3[hddtemp]: system uptime
Legend4[hddtemp]: partition df
Gnomeデスクトップのパネルに温度表示のアイコンを表示させたいときは、gnome-applet-sensors をインストールする。
[root@localhost ~]# yum install gnome-applet-sensors
そのほかのデータをSNMP経由で知りたいとき…
snmpwalkで必要なMIBを探し出し、表示されたラベルをMRTGで利用できる形に変換する
[root@localhost ~]# snmpwalk -v 1 -c public localhost .1.3.6.1.4.1.2021 | less
[root@localhost ~]# snmptranslate -On UCD-DISKIO-MIB::diskIONRead.17