!!!参考 https://wiki.archlinux.jp/index.php/S.M.A.R.T. https://qiita.com/rhap/items/a220483696b8d17b4090 http://www.atmarkit.co.jp/flinux/rensai/linuxtips/521smartinfo.html http://linux.just4fun.biz/%E9%80%86%E5%BC%95%E3%81%8DUNIX%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89/smartctl%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%A6%E3%81%BF%E3%82%8B.html https://www.systemworks.co.jp/ex_spindown.php !!!準備 smartmontools が必要。インストールされていない場合は yum install smartmontools でインストール。 smartd がデーモンとして登録される。 !!!基本的なコマンド ,コマンド,役割 ,smartctl --scan,サーバが認識しているHDDの一覧を取得する ,smartctl /dev/sda -i,一覧からそれぞれのHDDの詳細を確認する ,smartctl /dev/sdb -c,HDDが対応しているテストの種類と所要時間を確認する ,smartctl /dev/sdb -a,すべての情報を確認する ,smartctl -t short /dev/sda,スキャンを実行する ,smartctl -l selftest /dev/sda, スキャンログを確認する !!!HDDが対応しているか確認 smartctl /dev/sda -i で SMART support is: Available - device has SMART capability. SMART support is: Enabled が出力されていれば対応している。 !!!スキャンを行う スキャンのタイプはshortとlongがある。 所要時間は systemctl /dev/sda -c または systemctl /dev/sda -a で確認できる。 shortでスキャンする。 smartctl -t short /dev/sda スキャン後のログを確認する。 smartctl -l selftest /dev/sda スキャンを中断する smartctl -X /dev/sda !!!定期的にスキャンする smartdサービスによってHDDの監視ができる。 標準では30分毎にチェックしている。 /etc/sysconfig/smartmontools を編集することで30分(1800秒)の設定を変更できる。 また、セルフテストをスケジューリングできる。 smartdの設定ファイルは /etc/smartmontools/smartd.conf にある。標準では以下のようになっている。 DEVICESCAN -H -m root -M exec /usr/libexec/smartmontools/smartdnotify -n standby,10,q これを以下のように変更する。 DEVICESCAN -a -o on -S on -n standby,q -s (S/../.././02|L/../../6/03) -W 4,35,40 -m :DEVICESCAN: smartd は全てのディスクを監視対象にし、監視を実行する :-a:全ての属性を監視する :-o on: 自動オンラインデータ収集を有効化する :-S on:自動属性保存を有効化する :-n standby,q:ディスクが待機中の時チェックを実行せず、ディスクアクセスが発生しないようにログに書き込まない。 standby,10,q のように表記すると、10回スキップし、11回目はディスクが待機中であってもチェックを実施する。 :-s:スケジュールを指定 -s T/MM/DD/d/HH ,項目,意味 ,T,L=ロングセルフテスト{{br}}S=ショートセルフテスト ,MM,月 (01 = 1月 〜 12 = 12月) ,DD,日 (01 = 1日 〜 31 = 31日) ,d,曜日 (1 = 月曜日 〜 7 = 日曜日) ,HH,間 (00 = 0時 〜 23 = 23時) :-W: 温度を監視する。 -W 4,35,40 は温度が4度以上変わった時と35度に到達した時にログを記録し、さらに温度が40度と危険なときにはログを取ってメールを送信。 :-m:メールの送信先 30分毎にディスクを監視し、指定されたスケジュールでセルフテストを実行する。 ただし、30分毎のチェックの際にHDDがスタンバイになっている場合は何もしない。 (セルフテストはスタンバイ中であっても実行される) !!メールの送信テスト DEVICESCAN -m example@example.com -M test とするとメールの送信テストができる。 systemctl reload smartd.service で設定を再読込するとメールが送信される。 !!!出力結果の見方 !!HDDの情報確認 /usr/sbin/smartctl -a /dev/sda | less ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE 1 Raw_Read_Error_Rate 0x000b 100 100 016 Pre-fail Always - 0 2 Throughput_Performance 0x0005 100 100 050 Pre-fail Offline - 0 3 Spin_Up_Time 0x0007 125 125 024 Pre-fail Always - 160 (Average 160) 4 Start_Stop_Count 0x0012 100 100 000 Old_age Always - 967 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 095 095 000 Old_age Always - 38771 10 Spin_Retry_Count 0x0013 100 100 060 Pre-fail Always - 0 12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 967 192 Power-Off_Retract_Count 0x0032 098 098 000 Old_age Always - 2676 193 Load_Cycle_Count 0x0012 098 098 000 Old_age Always - 2676 194 Temperature_Celsius 0x0002 166 166 000 Old_age Always - 36 (Min/Max 4/57) 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 253 000 Old_age Always - 0 WHEN_FAILED が - なら問題ない。 VALUE(値)がTHRESH(しきい値)を下回っていると、WHEN_FAILEDにFAILING_NOW等が表示される。 TYPEは、その項目の重要度みたいな感じ。 ,TYPE,WHEN_FAILEDなし, WHEN_FAILEDあり ,Pre-fail,問題なし,故障 ,Old_age,問題なし,寿命 !!shortテスト smartctl -t short /dev/sda smartctl 5.42 2011-10-20 r3458 [x86_64-linux-2.6.18-348.3.1.el5] (local build) Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net === START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION === Sending command: "Execute SMART Short self-test routine immediately in off-line mode". Drive command "Execute SMART Short self-test routine immediately in off-line mode" successful. Testing has begun. Please wait 1 minutes for test to complete. Test will complete after Mon Apr 15 18:36:23 2013 Use smartctl -X to abort test. 実行後、コマンドラインに戻るがバックグラウンドでテストを実行している。 メッセージ内に「Please wait 1 minutes for test to complete.」とある。 一分程度待ってから smartctl -l selftest /dev/sda でテストの結果を確認できる。 !!longテスト smartctl -t long /dev/sda smartctl 5.42 2011-10-20 r3458 [x86_64-linux-2.6.18-348.3.1.el5] (local build) Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net === START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION === Sending command: "Execute SMART Extended self-test routine immediately in off-line mode". Drive command "Execute SMART Extended self-test routine immediately in off-line mode" successful. Testing has begun. Please wait 131 minutes for test to complete. Test will complete after Mon Apr 15 21:24:39 2013 Use smartctl -X to abort test. 結果は smartctl -l selftest /dev/sda !!テストの中断 smartctl -X でテストの中断ができる。 smartctl -X /dev/sda smartctl 5.42 2011-10-20 r3458 [x86_64-linux-2.6.18-348.3.1.el5] (local build) Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net === START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION === Sending command: "Abort SMART off-line mode self-test routine". Self-testing aborted! {{category2 OS,Linux}}