* HDDの温度監視 [#q4a5e5af]
** smartmontoolsのインストール [#s8cc8cd3]
# apt-get install smartmontools
パッケージリストを読みこんでいます... 完了
依存情報ツリーを作成しています... 完了
以下のパッケージが新たにインストールされます:
smartmontools
アップグレード: 0 個, 新規インストール: 1 個, 削除: 0 個, 保留: 1 個
351kB のアーカイブを取得する必要があります。
展開後に 608kB のディスク容量が追加消費されます。
取得:1 http://updates.vinelinux.org 3.1/i386/plus smartmontools 5.33-1vl0.6 [351kB]
351kB を 1s 秒で取得しました (196kB/s)
変更を適用しています...
Preparing... ########################################### [100%]
Note that you can use a configuration file /etc/smartd.conf to control the
startup behavior of the smartd daemon. See man 8 smartd for details.
Run "/sbin/chkconfig --add smartd", to start smartd service on system boot
1:smartmontools ########################################### [100%]
Run "/etc/rc.d/init.d/smartd start" to start smartd service now.
完了
**/dev/hdaの情報を表示 [#gb765256]
# smartctl -a /dev/hda
smartctl version 5.33 [i686-pc-linux-gnu] Copyright (C) 2002-4 Bruce Allen
Home page is http://smartmontools.sourceforge.net/
:
:
193 Load_Cycle_Count 0x0012 100 100 050 Old_age Always - 248
194 Temperature_Celsius 0x0002 122 122 000 Old_age Always - 45 (Lifetime Min/Max 13/61)
196 Reallocated_Event_Count 0x0032 100 100 000 Old_age Always - 0
:
:
>194 Temperature_Celsius・・・が表示されればOKです。右っ側の45という数字が現在の温度です。
**自動起動の設定 [#sebe161d]
# chkconfig --level 3 smartd on
# chkconfig --list smartd
snmpd 0:off 1:off 2:off 3:on 4:off 5:off 6:off
**温度取得スクリプトの作成 [#ndbfe556]
/usr/sbin/smartctl -A /dev/hdaの結果から温度の値のみをスクリプトで取得してMRTGに渡すことにします。
# vi /usr/local/mrtg-2/hdd_temp.sh
>新規に作成します。
#!/bin/sh
/usr/sbin/smartctl -A /dev/hda|grep Temperature_Celsius|awk '{print $10}{print $10}'
MRTGは入力が2系統なためprintで同じデータを2つ出力しています。
実行権限を与える
# chmod 755 /usr/local/mrtg-2/hdd_temp.sh
**mrtg.cfgの編集 [#xd146d27]
# vi /usr/local/mrtg-2/lib/mrtg.cfg
>追加
### HDD Temperature ###
Target[htemp]: `/usr/local/mrtg-2/hdd_temp.sh`
MaxBytes[htemp]: 56
Options[htemp]: gauge, growright, absolute, integer, nopercent, noinfo
Unscaled[htemp]: dwmy
YLegend[htemp]: Temperature
ShortLegend[htemp]: deg.
LegendI[htemp]: TEMP
LegendO[htemp]: TEMP
Legend1[htemp]: HDD温度
Legend2[htemp]: HDD温度
Title[htemp]: HDDの温度
PageTop[htemp]: <H1>HDDの温度</H1>
**実行 [#v037865c]
# /usr/local/mrtg-2/bin/mrtg /usr/local/mrtg-2/lib/mrtg.cfg
**インデックスページを作る [#rf8d606a]
# /usr/local/mrtg-2/bin/indexmaker --columns=1 \
--addhead="<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=euc-jp\">" \
/usr/local/mrtg-2/lib/mrtg.cfg > /home/httpd/mrtg/index.html
*CPUの温度監視 [#r44d9d48]
ハードウェアのセンサ情報を取得するにはI2CとLM Sensorsが必要らしい。
初め、最新のI2C 2.9.1 と LM Sensors 2.9.1 でやったがうまく動いてくれなかったので、旧バージョンのlm_sensors-2.7.0 をインストールしました。Vine Linux 3.1はカーネルにi2cを含んでいるのでi2c-2.7.0は入れなくいいようです。
ちなみに、PCはHITACHI FLORA 330 DK3です。このPCはACERのOEMでS57Lというマザーボードを搭載しています。チップセットにはSiS630が、センサチップにはITE8705Fが使われています。
**lm_sensorsのインストール [#d21df0d6]
http://secure.netroedge.com/%7Elm78/index.html
# wget http://secure.netroedge.com/%7Elm78/archive/lm_sensors-2.7.0.tar.gz
--16:37:54-- http://secure.netroedge.com/%7Elm78/archive/lm_sensors-2.7.0.tar.gz
=> `lm_sensors-2.7.0.tar.gz'
secure.netroedge.com をDNSに問いあわせています... 206.228.191.3
secure.netroedge.com[206.228.191.3]:80 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 595,379 [application/x-tar]
100%[==============================================>] 595,379 174.73K/s ETA 00:00
16:37:58 (156.57 KB/s) - `lm_sensors-2.7.0.tar.gz' を保存しました [595379/595379]
# tar zxf lm_sensors-2.7.0.tar.gz
# cd lm_sensors-2.7.0
makeするのに.configファイルが必要なので、自分のマシンに合ったものをコピーしてください。
# ls /usr/src/linux/configs/
kernel-2.4.27-athlon-smp.config kernel-2.4.27-i586-smp.config
kernel-2.4.27-athlon.config kernel-2.4.27-i586.config
kernel-2.4.27-i386-BOOT.config kernel-2.4.27-i686-smp.config
kernel-2.4.27-i386-smp.config kernel-2.4.27-i686.config
kernel-2.4.27-i386.config
# cp /usr/src/linux/configs/kernel-2.4.26-i686.config /usr/src/linux/.config
# make
# make install
**センサの自動検出 [#c9bf8d37]
# prog/detect/sensors-detect
適当にEnterを押していく。
**起動してみる [#bdda57fd]
# prog/init/lm_sensors.init start
Starting up sensors: starting module __i2c-sis630__
starting module __i2c-isa__
starting module __eeprom__
starting module __sis5595__
starting module __it87__
[ OK ]
-起動しない場合
# vi /etc/ld.so.conf
>に以下を追加
/usr/local/lib
<
# ldconfig
**センサ情報を見る [#oef3eab1]
# sensors
eeprom-i2c-0-50
Adapter: SMBus SIS630 adapter at f080
Algorithm: Non-I2C SMBus adapter
Memory type: SDRAM DIMM SPD
Memory size (MB): 128
eeprom-i2c-0-51
Adapter: SMBus SIS630 adapter at f080
Algorithm: Non-I2C SMBus adapter
Memory type: SDRAM DIMM SPD
Memory size (MB): 256
it87-isa-0290
Adapter: ISA adapter
Algorithm: ISA algorithm
VCore 1: +1.74 V (min = +1.53 V, max = +1.87 V)
VCore 2: +2.56 V (min = +2.25 V, max = +2.75 V)
+3.3V: +6.64 V (min = +2.96 V, max = +3.60 V) ALARM
+5V: +5.17 V (min = +4.50 V, max = +5.48 V)
+12V: +11.84 V (min = +11.36 V, max = +13.80 V)
-12V: -27.36 V (min = -15.86 V, max = -13.40 V) ALARM
-5V: -13.64 V (min = -10.13 V, max = -9.44 V) ALARM
Stdby: +0.00 V (min = +4.50 V, max = +5.48 V) ALARM
VBat: +3.32 V
fan1: 0 RPM (min = 3000 RPM, div = 2) ALARM
fan2: 3924 RPM (min = 3000 RPM, div = 2)
fan3: 0 RPM (min = 3000 RPM, div = 2)
Temp1/MB: +76庵 (min = +20庵, max = +60庵)
Temp2/CPU: -79庵 (min = +20庵, max = +60庵)
Temp3: +55庵 (min = +20庵, max = +60庵)
Tempの値が可笑しいので修正します。ITE8705Fのドキュメントがdoc/chips/it87に有ったのでそれを参考にmodules.confを編集します。
# vi /etc/modules.conf
>に以下を追加
options it87 temp_type=0x31
temp_typeをいろいろ変えてみる。
-(抜粋)doc/chips/it87の表
Legal values:
sensor1 sensor2 sensor3 value
------- ------- ------- -----
diode diode diode 0x07
diode diode thermistor 0x23
diode thermistor diode 0x15
diode thermistor thermistor 0x31
thermistor diode diode 0x0e
thermistor diode thermistor 0x2a ** default
thermistor thermistor diode 0x1c
thermistor thermistor thermistor 0x38
しかし自分のPCではtemp_typeをどうやってもTemp2とTemp3がまともな値にならない。
Temp1/MB: +39庵 (min = +20庵, max = +60庵)
Temp2/CPU: +95庵 (min = +20庵, max = +60庵)
Temp3: +55庵 (min = +20庵, max = +60庵)
仕方ないのでTemp1のデータのみ使う。上の結果ではTemp1/MBとなってるが実際はCPUみたいだ。CGIスクリプトにF5アタックを行ったら急激に変化したのでたぶんCPUだろう。sensorsの表記を編集したい場合は/etc/sensors.confをいじればよい。
**不要なモジュールを読み込まないようにする [#l15c8813]
logを見るとエラーが出ているので温度取得に関係ないモジュールを外す。
# vi /etc/sysconfig/lm_sensors
>
#MODULE_0=i2c-sis630
MODULE_0=i2c-isa
#MODULE_2=eeprom
#MODULE_3=sis5595
MODULE_1=it87
**自動起動の設定 [#q5a025e2]
起動スクリプトのコピー
# cp prog/init/lm_sensors.init /etc/rc.d/init.d/lm_sensors
# chkconfig lm_sensors on
リブートして動作することを確認する。
**CPU温度値の取得 [#rebc4ab9]
CPUの温度は
# cat /proc/sys/dev/sensors/it87-isa-0290/temp1
60.0 20.0 35.0
を見ることでも得られる。
なので、ここの値をスクリプトで取得してMRTGに渡すことにする。
# vi /usr/local/mrtg-2/cpu_temp.sh
>新規に作成します。
#!/bin/sh
awk '{print int($3)}{print int($3)}' /proc/sys/dev/sensors/it87-isa-0290/temp1
MRTGは入力が2系統なためprintで同じデータを2つ出力しています。
実行権限を与える
# chmod 755 /usr/local/mrtg-2/cpu_temp.sh
**mrtg.confの編集 [#i4f61bc4]
# vi /usr/local/mrtg-2/lib/mrtg.cfg
>追加
### CPU Temperature ###
Target[ctemp]: `/usr/local/mrtg-2/cpu_temp.sh`
MaxBytes[ctemp]: 48
Options[ctemp]: gauge, growright, absolute, integer, nopercent, noinfo
Unscaled[ctemp]: dwmy
YLegend[ctemp]: Temperature
ShortLegend[ctemp]: deg.
LegendI[ctemp]: TEMP
LegendO[ctemp]: TEMP
Legend1[ctemp]: CPU温度
Legend2[ctemp]: CPU温度
Title[ctemp]: CPUの温度
PageTop[ctemp]: <H1>CPUの温度</H1>
**実行 [#h33e3dd5]
# /usr/local/mrtg-2/bin/mrtg /usr/local/mrtg-2/lib/mrtg.cfg
何回か実行してエラーが出なくなればOK。
**インディクスページの作成 [#u4828302]
# /usr/local/mrtg-2/bin/indexmaker --columns=1 \
--addhead="<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=euc-jp\">" \
/usr/local/mrtg-2/lib/mrtg.cfg > /home/httpd/mrtg/index.html
*CPUの温度監視(ノートパソコンの場合) [#wbbf3e6d]
ノートパソコンの場合、センサチップが搭載されていない場合が多い。その代わり、ACPIにより温度取得ができる。
以下は、IBM Thinkpad X23(低電圧版モバイルPentium III-M 866MHz)の話。
Thinkpad X23では、ACPIによりCPUの温度を取得できる。
**モジュールを組み込む [#vbf33dc6]
# modprobe -l |grep acpi
/lib/modules/2.4.27-0vl7/kernel/drivers/acpi/asus_acpi.o
/lib/modules/2.4.27-0vl7/kernel/drivers/acpi/processor.o
/lib/modules/2.4.27-0vl7/kernel/drivers/acpi/thermal.o
/lib/modules/2.4.27-0vl7/kernel/drivers/acpi/toshiba_acpi.o
/lib/modules/2.4.27-0vl7/kernel/drivers/hotplug/acpiphp.o
thermal.oが関係しそうなモジュールなので、
# modprobe thermal
とやると組み込める。
lsmodでthermalがあればOK。
# lsmod
Module Size Used by Tainted: P
thermal 8068 0
:
:
/proc/acpiにthermal_zoneが現れているはずなので、
# cat /proc/acpi/thermal_zone/THM0/temperature
temperature: 49 C
でCPUの温度が表示される。
ちなみに、
# modprobe processor
を組み込むと、/proc/acpiにprocessorが現れて、
# cat /proc/acpi/processor/CPU/performance
state count: 2
active state: P0
states:
*P0: 733 MHz, 12500 mW, 500 uS
P1: 466 MHz, 9500 mW, 500 uS
でCPUの情報などを確認できる。
起動時に自動的に組み込まれるように、
# vi /etc/rc.d/rc.local
> 一番下に追加
modprobe thermal
あとは、上と同じようにシェルスクリプトで取得してMRTGに渡せばよい。
* コメント [#e6ca8bcc]
#pcomment(MRTGで温度監視/コメント)