ページへ戻る

− Links

 印刷 

GentooLinuxな生活​/サーバー監視方法で悩む のソース :: Nest Of Hawk

xpwiki:GentooLinuxな生活/サーバー監視方法で悩むのソース

« Prev[3]  
[[Gentoo Linuxな生活/システム管理関連]]

*サーバの監視に必要なこと [#xf4db2f8]
サーバ監視で必要なことと言えば、
-ちゃんと動いているか?

これに尽きると思います。で、ちゃんと動かなくなる要因といえば、
-ソフトの異常
-ハードの異常

この2つですね。ソフトの異常はインストールすればすぐにわかります。ハードの異常は、ある日突然やってきたりします。なので、予兆があるかどうかは、日々の監視が必要なのです。

*何を見ておこうか [#x99f8170]
まず何が壊れると一番まずいか。HDDです。HDDは消耗品ですし、寿命も比較的短いです。ですので、サーバのトラブルと言うと、大体HDDクラッシュが原因です。で、データが論理的に壊れるのは、データ管理に注意さえすれば何とかなります。ハードのクラッシュについては、温度が非常に重要なファクターを持っていると言われます。

*温度を監視しよう [#x2400f9f]
最近のPCは、CPUの発熱も厳しいところから、センサーチップを搭載していたりします。ですので、このセンサーチップを読み取るツールがあればいろんな情報を見ることができます。

**lm_sensors [#f89d78bf]
lm_sensorsと言うツールで、センサーチップの情報を見ることができます。

 # emerge lm_sensors

インストール完了~
**設定 [#yb15511a]
***カーネル [#z2dc6f2d]
まずカーネルのI2Cドライバーコンフィグレーションを有効化してやります。
 <*> I2C support
 <M>   I2C device interface
         I2C Algorithms  --->
         I2C Hardware Bus support  --->
         Hardware Sensors Chip support  --->
         Other I2C Chip support  --->
 
んで、I2C Hardware Bus support や、Hardware Sensors Chip supportも、有効にしておいてやりましょうね。

***lm_sensors側 [#yded695f]
 # sensors_detect

コマンドを投入します。するてーと、メニュー形式で設定を保存してくれます。あとは
 # rc-update add lm_sensors default

でlm_sensorsを起動時に有効にするようにするとi2cデバイスを読み込んでくれます。

**使い方 [#kffd80b9]
 # sensors
 w83697hf-isa-0290
 Adapter: ISA adapter
 VCore:     +1.46 V  (min =  +1.71 V, max =  +1.89 V)
 +3.3V:     +3.20 V  (min =  +3.14 V, max =  +3.47 V)
 +5V:       +4.89 V  (min =  +4.76 V, max =  +5.24 V)
 +12V:     +11.55 V  (min = +10.82 V, max = +13.19 V)
 -12V:     -11.70 V  (min = -13.18 V, max = -10.80 V)
 -5V:       -7.71 V  (min =  -5.25 V, max =  -4.75 V)
 V5SB:      +5.54 V  (min =  +4.76 V, max =  +5.24 V)
 VBat:      +3.06 V  (min =  +2.40 V, max =  +3.60 V)
 fan1:        0 RPM  (min = 51923 RPM, div = 2)
 fan2:        0 RPM  (min = 225000 RPM, div = 2)
 temp1:       +29°C  (high =    +2°C, hyst =    +0°C)   sensor = thermistor
 temp2:     +17.0°C  (high =   +80°C, hyst =   +75°C)   sensor = thermistor
 alarms:   Chassis intrusion detection                      ALARM
 beep_enable:
          Sound alarm disabled
 
 eeprom-i2c-1-51
 Adapter: SiS96x SMBus adapter at 0x10c0
 Memory type:            DDR SDRAM DIMM
 Memory size (MB):       512
 
 eeprom-i2c-1-50
 Adapter: SiS96x SMBus adapter at 0x10c0
 Memory type:            DDR SDRAM DIMM
 Memory size (MB):       512
 
 eeprom-i2c-0-50
 Adapter: ivtv i2c driver #0
 Unknown EEPROM type (255).
 
 adm1030-i2c-1-2e
 Adapter: SiS96x SMBus adapter at 0x10c0
 CPU Fan:  2537 RPM  (min = 1323 RPM, div = 2)
 SYS Temp:  +46.8°C  (low  =    +0°C, high =   +60°C)
 SYS Crit:    +85°C
 CPU Temp:  +48.2°C  (low  =   +40°C, high =   +52°C)
 CPU Crit:    +85°C

ほれ、どうですか?ちゃんと出ましたでしょ?つーか、何気にCPUとか、筐体内の温度が高いんだよね。う~ん、対策考えなきゃ、かなー。

***ASUSマザーボードP8H77-Vでのsensor設定 [#r1dfdfb3]
2013年2月、サーバのマザーを交換したのですが、lm_sensorsでセンサーを検出してくれず、CPU温度しかモニタリングできなくなってしまいました。う~ん…と言うことで、いろいろ調べてみたところ、lm_sensorsを最新化するがよろしと。/etc/portage/package.keywordsに

 sys-apps/lm_sensors

を追加してsensors-detect。するとnct6775というセンサーチップが乗っていることが判明。しかし…このセンサーチップ、Linuxカーネル(3.6.11)には入ってないんだよねぇ…しかたがないのでぐぐったところ、Githubにドライバが登録されていることが判明。んで、以下のコマンド投入

 # git clone https://github.com/groeck/nct6775.git

カーネルドライバをチェックアウトしてきます。で、自力コンパイル…Makefileと格闘しましたが…

で、/etc/conf.d/lm_sensorsを以下で記述
 #
 # The format of this file is a shell script that simply defines variables:
 # HWMON_MODULES for hardware monitoring driver modules, and optionally
 # BUS_MODULES for any required bus driver module (for example for I2C or SPI).
 
 # Load modules at startup
 LOADMODULES=yes
 
 # Initialize sensors at startup
 INITSENSORS=yes
 
 HWMON_MODULES="coretemp nct6775"
 
 # For compatibility reasons, modules are also listed individually as variables
 #    MODULE_0, MODULE_1, MODULE_2, etc.
 # Please note that the numbers in MODULE_X must start at 0 and increase in
 # steps of 1. Any number that is missing will make the init script skip the
 # rest of the modules. Use MODULE_X_ARGS for arguments.
 #
 # You should use BUS_MODULES and HWMON_MODULES instead if possible.
 
 MODULE_0=coretemp
 MODULE_1=nct6775

で、sensorsコマンドを打ってみたら…
 acpitz-virtual-0
 Adapter: Virtual device
 temp1:        +27.8°C  (crit = +106.0°C)
 temp2:        +29.8°C  (crit = +106.0°C)
 
 coretemp-isa-0000
 Adapter: ISA adapter
 Physical id 0:  +38.0°C  (high = +85.0°C, crit = +105.0°C)
 Core 0:         +36.0°C  (high = +85.0°C, crit = +105.0°C)
 Core 1:         +36.0°C  (high = +85.0°C, crit = +105.0°C)
 Core 2:         +28.0°C  (high = +85.0°C, crit = +105.0°C)
 Core 3:         +30.0°C  (high = +85.0°C, crit = +105.0°C)
 
 nct6779-isa-0290
 Adapter: ISA adapter
 in0:                    +0.91 V  (min =  +0.00 V, max =  +1.74 V)
 in1:                    +1.02 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
 in2:                    +3.36 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
 in3:                    +3.36 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
 in4:                    +1.01 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
 in5:                    +2.04 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
 in6:                    +0.37 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
 in7:                    +3.47 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
 in8:                    +3.39 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
 in9:                    +1.06 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
 in10:                   +0.34 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
 in11:                   +0.17 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
 in12:                   +1.01 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
 in13:                   +1.02 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
 in14:                   +0.22 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
 fan1:                     0 RPM  (min =    0 RPM)
 fan2:                  1140 RPM  (min =    0 RPM)
 fan3:                     0 RPM  (min =    0 RPM)
 fan4:                     0 RPM  (min =    0 RPM)
 fan5:                     0 RPM  (min =    0 RPM)
 SYSTIN:                 +24.0°C  (high =  +0.0°C, hyst =  +0.0°C)  ALARM  sensor = thermistor
 CPUTIN:                 +31.0°C  (high = +80.0°C, hyst = +75.0°C)  sensor = thermistor
 AUXTIN0:                +95.0°C    sensor = thermistor
 AUXTIN1:                +96.0°C    sensor = thermistor
 AUXTIN2:               +104.0°C    sensor = thermistor
 AUXTIN3:                +17.0°C    sensor = thermal diode
 PCH_CHIP_CPU_MAX_TEMP:   +0.0°C
 PCH_CHIP_TEMP:           +0.0°C
 PCH_CPU_TEMP:            +0.0°C
 PCH_MCH_TEMP:            +0.0°C
 cpu0_vid:              +0.000 V
 intrusion0:            ALARM
 intrusion1:            ALARM

見事データがとれました。やれやれ…

**smartデーモン [#b25ea45e]
smartとは、HDDの自己診断機能S.M.A.R.Tのことで、これを導入すると、S.M.A.R.T対応HDDでは自己診断して、やばそう!ってのを教えてくれたりします。

***インストール [#q25463f0]
# emerge smartmontools

終了~
***設定 [#a6649f4b]
/etc/smartd.confを開きます。ほとんど書いてある例を参考にすればいいのですが、サンプルを参考にちょっと変えて、私はこんな感じで
 # DEVICESCAN ←コメントアウトします。
 /dev/sda -a -d sat -o on -S on -s (S/../.././04|L/../../6/05) -m mailowner

説明すると、まずDEVICESCANを付けると、それ以降の設定は全て無視されるそうなので、まずはコメントアウト。-aはヘルスチェックステータス、Usageアトリビュートのエラーチェック、Prefailerアトリビュートチェック、Usageアトリビュートチェック、errorログ、selftestログなどを有効にするオプション、-d satは、ATAをSCSIレイヤ使用して使用します。いわゆるSATA向けの設定。-oはオフラインテスト、-S はオートセーブ、-sはショートセルフテストを毎日4時、ロングセルフテストを土曜日の5時からスタート。で-mはステータスの変化があったらmailownerにメールする、てオプション。

これでsmartdを起動すればOK

 # rc-update add smartd default

これでS.M.A.R.Tデーモン監視がスタートします。ちなみにコマンドラインでも情報が取れるとです。
 # smartctl -a /dev/hda
 === START OF INFORMATION SECTION ===
 Device Model:     HDS722516VLAT20
 Serial Number:    VNR4GMC4GJR2KM
 Firmware Version: V34OA60A
 User Capacity:    164,696,555,520 bytes
 Device is:        In smartctl database [for details use: -P show]
 ATA Version is:   6
 ATA Standard is:  ATA/ATAPI-6 T13 1410D revision 3a
 Local Time is:    Sun Apr 17 00:10:59 2005 JST
 SMART support is: Available - device has SMART capability.
 SMART support is: Enabled
 
 === START OF READ SMART DATA SECTION ===
 SMART overall-health self-assessment test result: PASSED
 
 General SMART Values:
 Offline data collection status:  (0x00) Offline data collection activity
                                        was never started.
                                        Auto Offline Data Collection: Disabled.
 Self-test execution status:      (   0) The previous self-test routine completed
                                        without error or no self-test has ever
                                        been run.
 Total time to complete Offline
 data collection:                 (3585) seconds.
 Offline data collection
 capabilities:                    (0x1b) SMART execute Offline immediate.
                                        Auto Offline data collection on/off support.
                                        Suspend Offline collection upon new
                                        command.
                                        Offline surface scan supported.
                                        Self-test supported.
                                        No Conveyance Self-test supported.
                                        No Selective Self-test supported.
 SMART capabilities:            (0x0003) Saves SMART data before entering
                                        power-saving mode.
                                        Supports SMART auto save timer.
 Error logging capability:        (0x01) Error logging supported.
                                        General Purpose Logging supported.
 Short self-test routine
 recommended polling time:        (   1) minutes.
 Extended self-test routine
 recommended polling time:        (  60) minutes.
 
 SMART Attributes Data Structure revision number: 16
 Vendor Specific SMART Attributes with Thresholds:
 ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x000b   100   100   060    Pre-fail  Always       -       0
  2 Throughput_Performance  0x0005   100   100   050    Pre-fail  Offline      -       0
  3 Spin_Up_Time            0x0007   134   134   024    Pre-fail  Always       -       229 (Average 216)
  4 Start_Stop_Count        0x0012   100   100   000    Old_age   Always       -       55
  5 Reallocated_Sector_Ct   0x0033   100   100   005    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x000b   100   100   067    Pre-fail  Always       -       0
  8 Seek_Time_Performance   0x0005   100   100   020    Pre-fail  Offline      -       0
  9 Power_On_Hours          0x0012   099   099   000    Old_age   Always       -       8711
 10 Spin_Retry_Count        0x0013   100   100   060    Pre-fail  Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       55
 192 Power-Off_Retract_Count 0x0032   100   100   050    Old_age   Always       -       415
 193 Load_Cycle_Count        0x0012   100   100   050    Old_age   Always       -       415
 194 Temperature_Celsius     0x0002   125   125   000    Old_age   Always       -       44 (Lifetime Min/Max 25/54)
 196 Reallocated_Event_Count 0x0032   100   100   000    Old_age   Always       -       0
 197 Current_Pending_Sector  0x0022   100   100   000    Old_age   Always       -       0
 198 Offline_Uncorrectable   0x0008   100   100   000    Old_age   Offline      -       0
 199 UDMA_CRC_Error_Count    0x000a   200   200   000    Old_age   Always       -       0
 
 SMART Error Log Version: 1
 No Errors Logged
 
 SMART Self-test log structure revision number 1
 No self-tests have been logged.  [To run self-tests, use: smartctl -t]
 
 
 Device does not support Selective Self Tests/Logging

こんな感じで情報が出てきます。かなり細かいでしょ?これで相当の情報が得られるはず。セルフテストでNGになってから壊れるとは限りませんけど、最低限の保障はほしいもんね。

« Prev[3]