MRTGで温度監視 のバックアップ差分(No.3)


  • 追加された行はこの色です。
  • 削除された行はこの色です。
*概要 [#ta553409]
MRTGでCPUの温度監視ができるようにします。

ハードウェアのセンサ情報を取得するには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/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を編集する。

-(抜粋)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

 # vi /etc/modules.conf
に以下を追加
 options it87 temp_type=0x31

temp_typeをいろいろ変えてみる。

しかし自分のPCではtemp_typeをどうやってもTemp2とTemp3がまともな値にならない。

仕方ないので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の温度は
 # less /proc/sys/dev/sensors/it87-isa-0290/temp1
を見ることでも得られる。

なので、ここの値をスクリプトで取得してMRTGに渡すことにする。

 # vi /usr/local/mrtg-2/cpu_temp.sh

 #!/bin/sh
 awk '{print int($3+0.5)}' /proc/sys/dev/sensors/it87-isa-0290/temp1
 awk '{print int($3+0.5)}' /proc/sys/dev/sensors/it87-isa-0290/temp1
 awk '{print int($3)}' /proc/sys/dev/sensors/it87-isa-0290/temp1
 awk '{print int($3)}' /proc/sys/dev/sensors/it87-isa-0290/temp1

実行権限を与える
 # 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

* コメント [#e6ca8bcc]
#pcomment(MRTGで温度監視/コメント)