ラベル lm_sensors の投稿を表示しています。 すべての投稿を表示
ラベル lm_sensors の投稿を表示しています。 すべての投稿を表示

2012年3月27日火曜日

NET-SNMP、lm_sensors、MRGTによる監視

NET-SNMPパッケージをインストールする


# yum install net-snmp



NET-SNMPの設定を行う。


# vi /etc/snmp/snmpd.conf

#com2sec notConfigUser default public <-コメントアウト
com2sec local localhost private <-追加
com2sec mynetwork 192.100.100.0/24 public <-追加
#view systemview included .1.3.6.1.2.1.1 <-コメントアウト #view systemview included .1.3.6.1.2.1.25.1.1 <-コメントアウト view all included .1 80 <-追加 #group notConfigGroup v1 notConfigUser<-コメントアウト #group notConfigGroup v2c notConfigUser<-コメントアウト group MyROGroup v1 mynetwork<-追加 group MyROGroup v2c mynetwork<-追加 ↓コメントアウト
#access notConfigGroup "" any noauth exact systemview none none
access MyROGroup "" any noauth exact all none none <-追加
access MyRWGroup "" any noauth exact all all none <-追加
disk / 10000 <-コメント外す


snmpdの起動と、自動起動設定。


# /etc/rc.d/init.d/snmpd start
snmpd を起動中: [ OK ]
# chkconfig snmpd on





MRGTパッケージをインストールする


# yum install mrtg



MRTGの設定を行う


設定ファイルの作成
# cfgmaker --ifref=descr --ifdesc=descr public@192.100.100.50 >
/etc/mrtg/mrtg.cfg


mrtg.cfg を編集
# vi /etc/mrtg/mrtg.cfg

# WorkDir: /home/http/mrtg
WorkDir: /home/user/public_html/mrtg <- mrtgフォルダの設定
              (今回はユーザフォルダに置くことにする)

# Options[_]: growright, bits
Options[_]: growright, noinfo <- グラフの時間軸を左から右へ設定する

Language:eucjp <-追加


### Interface 2 >>...
TargetからPageTopまでの値 "[192.100.100.50_eth0]" をすべて
"[eth0]" に修正する。
<table>から</table>までの値(<table>タグ含む)をすべて削除する


最終行に下記値を追加する

### CPU Load Average ###
Target[cpu]: .1.3.6.1.4.1.2021.10.1.5.1&.1.3.6.1.4.1.2021.10.1.5.2:
MaxBytes[cpu]: 100
Unscaled[cpu]: dwmy
Options[cpu]: gauge, absolute, growright, noinfo, nopercent
YLegend[cpu]: CPU Load(%)
ShortLegend[cpu]: (%)
LegendI[cpu]: 1分間平均
LegendO[cpu]: 5分間平均
Legend1[cpu]: 1分間平均(%)
Legend2[cpu]: 5分間平均(%)
Title[cpu]: CPU Load Average
PageTop[cpu]: <H1>CPU Load Average</H1>


### Memory Free ####
Target[mem]: .1.3.6.1.4.1.2021.4.6.0&.1.3.6.1.4.1.2021.4.4.0:
MaxBytes1[mem]: 4010280
MaxBytes2[mem]: 6242296
Unscaled[mem]: dwmy
Options[mem]: gauge, absolute, growright, noinfo
YLegend[mem]: Mem Free(Bytes)
ShortLegend[mem]: Bytes
kilo[mem]: 1024
kMG[mem]: k,M,G,T,P
LegendI[mem]: Real
LegendO[mem]: Swap
Legend1[mem]: 空き物理メモリ[MBytes]
Legend2[mem]: 空きスワップメモリ[MBytes]
Title[mem]: Memory Free
PageTop[mem]: <H1>Memory Free</H1>


### Disk Used ####
Target[disk]: .1.3.6.1.4.1.2021.9.1.9.1&.1.3.6.1.4.1.2021.9.1.9.1:
MaxBytes[disk]: 100
Unscaled[disk]: dwmy
Options[disk]: gauge, absolute, growright, nopercent, noinfo
YLegend[disk]: Disk Used(%)
ShortLegend[disk]: (%)
LegendI[disk]: / Disk used
LegendO[disk]: / Disk Used
Legend1[disk]: / Disk used
Legend2[disk]: / Disk used
Title[disk]: Disk Used
PageTop[disk]: <H1>Disk Used</H1>


### CPU Temperature ####
Target[cputemp]: `/usr/bin/sensors | grep 'Core' |
awk '{print $3}' | sed -e 's/+//' -e 's/[^0-9+\.].*//'`
MaxBytes[cputemp]: 100
Title[cputemp]: CPU Temperature
PageTop[cputemp]: <H1>CPU Temperature</H1>
Options[cputemp]: growright,absolute,gauge,nopercent,noinfo
WithPeak[cputemp]: ymw
unscaled[cputemp]: dwmy
YLegend[cputemp]: Temperature
ShortLegend[cputemp]: C
LegendI[cputemp]: Core 0
LegendO[cputemp]: Core 1
Legend1[cputemp]: Core 0
Legend2[cputemp]: Core 1


### M/B Temperature ####
Target[mbtemp]: `/usr/bin/sensors | grep 'temp1' |
awk '{print $2}{print $2}' | sed -e 's/+//' -e 's/[^0-9+\.].*//'`
MaxBytes[mbtemp]: 100
Title[mbtemp]: M/B Temperature
PageTop[mbtemp]: <H1>M/B Temperature</H1>
Options[mbtemp]: growright,absolute,gauge,nopercent,noinfo
WithPeak[mbtemp]: ymw
unscaled[mbtemp]: dwmy
YLegend[mbtemp]: Temperature
ShortLegend[mbtemp]: C
LegendI[mbtemp]: Temp
LegendO[mbtemp]: Temp
Legend1[mbtemp]: M/B Temp
Legend2[mbtemp]: M/B Temp


前回 lm_sensors でCPU温度が取得できるようになった、今回は取得した温度をログに記録する。
lm_sensors を実行すると、下記のように表示される。
# sensors

acpitz-virtual-0
Adapter: Virtual device
temp1: +54.0°C (crit = +104.0°C)

coretemp-isa-0000
Adapter: ISA adapter
Core 0: +22.0°C (high = +80.0°C, crit = +100.0°C)
Core 1: +23.0°C (high = +80.0°C, crit = +100.0°C)



下記コマンドオプションを加えることで、温度(数値)だけ表示させることができる。
# /usr/bin/sensors | grep 'Core' |
awk '{print $3}' | sed -e 's/+//' -e 's/[^0-9+\.].*//'
22.0
23.0


M/B(Chipset)温度は、下記で取得。
# /usr/bin/sensors | grep 'temp1' |
awk '{print $2}{print $2}' | sed -e 's/+//' -e 's/[^0-9+\.].*//'
54.0
54.0


M/Bの温度取得については、MRTGの入力は2系統であるので、printで同じ値を2度出力している。


メモリーについては、freeコマンドで、メモリーとスワップの最大容量を確認して、それぞれ値を設定する。
# free
total used free shared buffers cached
Mem: 4010280 231876 3778404 0 12204 142772
-/+ buffers/cache: 76900 3933380
Swap: 6242296 0 6242296





保存したら、設定ファイルの文字コードをEUCに変換する。
設定ファイルのバックアップ
# cp /etc/mrtg/mrtg.cfg /etc/mrtg/mrtg.cfg.org

nkfでコードをEUCに変換
# nkf -e /etc/mrtg/mrtg.cfg.org > /etc/mrtg/mrtg.cfg


なお、nkfがインストールされてない場合は、nkfパッケージをインストール。
# yum install nkf



MRTGの起動スクリプトを作っておく

# vi mrtg.sh

#!/bin/bash

LOCK=/var/lock/mrtg/mrtg_l
CONFCACHE=/var/lib/mrtg/mrtg.ok

export LANG=ja_JP.eucJP
mrtg /etc/mrtg/mrtg.cfg --lock-file $LOCK --confcache-file $CONFCACHE



# chmod 700 mrtg.sh <- 権限の付加




外部からアクセスできるように許可をする
# vi /etc/httpd/conf.d/mrtg.conf

#Alias /mrtg /var/www/mrtg
Alias /mrtg /home/user/public_html/mrtg <- 変更する

<Location /mrtg>
Order deny,allow
Deny from all
Allow from All <-追加
#Allow from 127.0.0.1
Allow from ::1
# Allow from .example.com
</Location>


設定の反映
# /etc/rc.d/init.d/httpd restart
httpd を停止中: [ OK ]
httpd を起動中: [ OK ]


とりあえずALLとして、アクセス制御は .htaccess で行えばよい。

crondが起動していない場合は、起動または再起動させる。
# service crond restart
crond を停止中: [ OK ]
crond を起動中: [ OK ]



動作確認


それぞれのグラフは [SeverIP]/mrtg/[label].html でアクセスできる。
たとえば、CPU温度であれば、http://192.100.100.50/mrtg/cputemp.html

2012年3月26日月曜日

lm_sensorsのインストール

CPU温度を確認するため、lm_sensorsをインストールする。XS35V2はSSD仕様のため、ディスク(SSD)の温度は計測しない(シリコンだから、たぶん80℃までは大丈夫なのかな?)

# yum install lm_sensors

Loaded plugins: fastestmirror, presto
Loading mirror speeds from cached hostfile
* base: www.ftp.ne.jp
* extras: www.ftp.ne.jp
* updates: www.ftp.ne.jp
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package lm_sensors.i686 0:3.1.1-10.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

============================================================
Package Arch Version Repository Size
============================================================
Installing:
lm_sensors i686 3.1.1-10.el6 base 122 k

Transaction Summary
============================================================
Install 1 Package(s)

Total download size: 122 k
Installed size: 343 k
Is this ok [y/N]: y
Downloading Packages:
Setting up and reading Presto delta metadata
Processing delta metadata
Package(s) data still to download: 122 k
lm_sensors-3.1.1-10.el6.i686.rpm | 122 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : lm_sensors-3.1.1-10.el6.i686 1/1

Installed:
lm_sensors.i686 0:3.1.1-10.el6

Complete!



続いて設定、設定は下記コマンドで行う、質問は基本[Enter]で処理。

# sensors-detect

Stopping lm_sensors: not configured, run sensors-detect [警告]
# sensors-detect revision 1.1
# System: Standard XS35
# Board: Shuttle B10IE01

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.

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

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

Some systems (mainly servers) implement IPMI, a set of common interfaces
through which system health data may be retrieved, amongst other things.
We first try to get the information from SMBIOS. If we don't find it
there, we have to read from arbitrary I/O ports to probe for such
interfaces. This is normally safe. Do you want to scan for IPMI
interfaces? (YES/no):
Probing for `IPMI BMC KCS' at 0xca0... No
Probing for `IPMI BMC SMIC' at 0xca8... No

Some hardware monitoring chips are 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 LM79' at 0x290... No
Probing for `Winbond W83781D' at 0x290... No
Probing for `Winbond W83782D' at 0x290... No

Lastly, we can probe the I2C/SMBus adapters for connected hardware
monitoring devices. This is the most risky part, and while it works
reasonably well on most systems, it has been reported to cause trouble
on some systems.
Do you want to probe the I2C/SMBus adapters now? (YES/no):
Using driver `i2c-i801' for device 0000:00:1f.3: Intel 82801G ICH7
Module i2c-dev loaded successfully.

Next adapter: i915 gmbus disabled (i2c-0)
Do you want to scan it? (YES/no/selectively):

Next adapter: i915 gmbus ssc (i2c-1)
Do you want to scan it? (YES/no/selectively):

Next adapter: i915 GPIOB (i2c-2)
Do you want to scan it? (YES/no/selectively):

Next adapter: i915 gmbus vga (i2c-3)
Do you want to scan it? (YES/no/selectively):

Next adapter: i915 GPIOA (i2c-4)
Do you want to scan it? (YES/no/selectively):

Next adapter: i915 gmbus panel (i2c-5)
Do you want to scan it? (YES/no/selectively):

Next adapter: i915 GPIOC (i2c-6)
Do you want to scan it? (YES/no/selectively):

Next adapter: i915 gmbus dpc (i2c-7)
Do you want to scan it? (YES/no/selectively):

Next adapter: i915 GPIOD (i2c-8)
Do you want to scan it? (YES/no/selectively):

Next adapter: i915 gmbus dpb (i2c-9)
Do you want to scan it? (YES/no/selectively):

Next adapter: i915 GPIOE (i2c-10)
Do you want to scan it? (YES/no/selectively):

Next adapter: i915 gmbus reserved (i2c-11)
Do you want to scan it? (YES/no/selectively):

Next adapter: i915 gmbus dpd (i2c-12)
Do you want to scan it? (YES/no/selectively):

Next adapter: i915 GPIOF (i2c-13)
Do you want to scan it? (YES/no/selectively):

Next adapter: SMBus I801 adapter at 0400 (i2c-14)
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'... No
Probing for `EDID EEPROM'... No

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

Driver `coretemp':
* Chip `Intel Core family thermal sensor' (confidence: 9)

Do you want to overwrite /etc/sysconfig/lm_sensors? (YES/no):
Starting lm_sensors: loading module coretemp [ OK ]
Unloading i2c-dev... OK



とりあえず、sensors を実行すると、次の値が出た。とりあえず、M/BとCPUの温度だけとれているようだ。

# sensors

acpitz-virtual-0
Adapter: Virtual device
temp1: +52.0°C (crit = +104.0°C)

coretemp-isa-0000
Adapter: ISA adapter
Core 0: +19.0°C (high = +80.0°C, crit = +100.0°C)
Core 1: +20.0°C (high = +80.0°C, crit = +100.0°C)



なお、lm-sensorsが対応していない場合は、下記URLからsensors-detectの最新版をダウンロードして実行。
http://dl.lm-sensors.org/lm-sensors/files/