Linuxマシンのハードディスクの温度を測る
Linuxマシンのハードディスクの温度を測る
0.改訂履歴
- 2006.06.22 新規作成
- 2006.06.23 SMARTがoffになっているときの確認
1.はじめに
このドキュメントでは,ハードディスクの温度を調べて,ログを記録する手順を説明する. 最近のハードディスクには,S.M.A.R.T.という規格でハードディスクのステータスがわかる機能があるが,その中から温度情報を取得し,定期的にログファイルに書き出す仕組みについて説明する.
2.smartctlコマンドを使ってHDDの状態を調べる
[root@artemis shinnai]# locate smartctl
/usr/share/man/man8/smartctl.8.gz
/usr/sbin/smartctl
[root@artemis shinnai]#
|
[root@artemis shinnai]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda6 18G 5.5G 12G 33% /
/dev/hda3 6.8G 4.0G 2.5G 63% /backup
/dev/hda1 99M 9.1M 85M 10% /boot
/dev/hda5 2.9G 56M 2.7G 2% /db
none 187M 0 187M 0% /dev/shm
/dev/hda2 9.7G 140M 9.0G 2% /www
[root@artemis shinnai]#
|
- デバイス名が,/dev/hdaということがわかる.
- -aオプションを使って,すべての情報を
[root@artemis shinnai]# /usr/sbin/smartctl -a /dev/hda
smartctl version 5.1-11 Copyright (C) 2002-3 Bruce Allen
Home page is http://smartmontools.sourceforge.net/
=== START OF INFORMATION SECTION ===
Device Model: FUJITSU MPG3409AT E
Serial Number: VH06T13057SJ
Firmware Version: 82B9
Device is: Not in smartctl database [for details use: -P showall]
ATA Version is: 5
ATA Standard is: ATA/ATAPI-5 T13 1321D revision 1
Local Time is: Thu Jun 22 12:13:32 2006 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
See vendor-specific Attribute list for marginal Attributes.
General SMART Values:
Off-line data collection status: (0x00) Offline data collection activity was
never started.
Auto Off-line 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 off-line
data collection: ( 50) seconds.
Offline data collection
capabilities: (0x1b) SMART execute Offline immediate.
Automatic timer 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: (0x0002) Does not save SMART data before
entering power-saving mode.
Supports SMART auto save timer.
Error logging capability: (0x01) Error logging supported.
No General Purpose Logging support.
Short self-test routine
recommended polling time: ( 2) minutes.
Extended self-test routine
recommended polling time: ( 54) minutes.
SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x000b 100 100 032 Pre-fail - 153818
2 Throughput_Performance 0x0005 100 100 020 Pre-fail - 0
3 Spin_Up_Time 0x0007 087 084 025 Pre-fail - 4
4 Start_Stop_Count 0x0012 096 096 016 Old_age - 2059
5 Reallocated_Sector_Ct 0x0033 100 100 024 Pre-fail - 0
7 Seek_Error_Rate 0x000b 100 060 020 Pre-fail - 684
8 Seek_Time_Performance 0x0005 100 100 019 Pre-fail - 0
9 Power_On_Hours 0x0012 013 013 020 Old_age FAILING_NOW 47516014
10 Spin_Retry_Count 0x0013 100 100 020 Pre-fail - 0
12 Power_Cycle_Count 0x0032 093 093 020 Old_age - 1115
194 Temperature_Celsius 0x0022 100 067 000 Old_age - 67
196 Reallocated_Event_Count 0x0033 100 100 024 Pre-fail - 0
197 Current_Pending_Sector 0x0010 100 100 020 Old_age - 0
198 Offline_Uncorrectable 0x0010 100 100 020 Old_age - 0
199 UDMA_CRC_Error_Count 0x000a 200 200 197 Old_age - 0
200 Multi_Zone_Error_Rate 0x000b 100 093 020 Pre-fail - 246
SMART Error Log Version: 1
No Errors Logged
SMART Self-test log, version number 1
No self-tests have been logged
[root@artemis shinnai]#
|
[root@artemis shinnai]# /usr/sbin/smartctl -a /dev/hda | grep Temperature
194 Temperature_Celsius 0x0022 100 067 000 Old_age - 67
[root@artemis shinnai]#
|
[root@artemis shinnai]# /usr/sbin/smartctl -a /dev/hda | grep Temperature | cut -c 78-
69
[root@artemis shinnai]#
|
[root@artemis bin]# cat TemperatureLog.sh
#!/bin/bash
export LOG_DATE=`date +%Y/%m/%d`
export LOG_TIME=`date +%T`
export LOG_TEMP=`/usr/sbin/smartctl -a /dev/hda | grep Temperature | cut -c 78-79`
export LOG_HOST=`hostname`
echo $LOG_DATE $LOG_TIME $LOG_HOST $LOG_TEMP >> /www/system/log/Temperature.log
[root@artemis bin]#
|
- 実行権限を設定して,実行してみる.
- ファイルの中身を確認する.
[root@artemis bin]# chmod ogu+x TemperatureLog.sh
[root@artemis bin]# ./TemperatureLog.sh
[root@artemis bin]# cat //www/system/log/Temperature.log
2006/06/22 12:36:33 artemis 69
[root@artemis bin]#
|
4.SMARTがオフの場合
- 使用している機械によっては,次のようにメッセージが出力される場合がある.
[root@juno shinnai]# /usr/sbin/smartctl -a /dev/hda
smartctl version 5.1-11 Copyright (C) 2002-3 Bruce Allen
Home page is http://smartmontools.sourceforge.net/
=== START OF INFORMATION SECTION ===
Device Model: HDS722580VLAT20
Serial Number: VNR21FC2RAPEML
Firmware Version: V32OA60A
Device is: Not in smartctl database [for details use: -P showall]
ATA Version is: 6
ATA Standard is: ATA/ATAPI-6 T13 1410D revision 3a
Local Time is: Fri Jun 23 12:54:43 2006 JST
SMART support is: Available - device has SMART capability.
SMART support is: Disabled
SMART Disabled. Use option -s with argument 'on' to enable it.
[root@juno shinnai]#
|
- このデバイスで,SMARTがoffになっているのでステータスが取得できないという事.
- よって,指示にあるとおりにOnにする.
[root@juno shinnai]# /usr/sbin/smartctl -s on /dev/hda
smartctl version 5.1-11 Copyright (C) 2002-3 Bruce Allen
Home page is http://smartmontools.sourceforge.net/
=== START OF ENABLE/DISABLE COMMANDS SECTION ===
SMART Enabled.
[root@juno shinnai]#
|
[root@juno shinnai]# /usr/sbin/smartctl -a /dev/hda
smartctl version 5.1-11 Copyright (C) 2002-3 Bruce Allen
Home page is http://smartmontools.sourceforge.net/
=== START OF INFORMATION SECTION ===
Device Model: HDS722580VLAT20
Serial Number: VNR21FC2RAPEML
Firmware Version: V32OA60A
Device is: Not in smartctl database [for details use: -P showall]
ATA Version is: 6
ATA Standard is: ATA/ATAPI-6 T13 1410D revision 3a
Local Time is: Fri Jun 23 12:56:05 2006 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:
Off-line data collection status: (0x00) Offline data collection activity was
never started.
Auto Off-line 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 off-line
data collection: (1828) seconds.
Offline data collection
capabilities: (0x1b) SMART execute Offline immediate.
Automatic timer 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: ( 31) minutes.
SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x000b 095 095 060 Pre-fail - 65553
2 Throughput_Performance 0x0005 100 100 050 Pre-fail - 0
3 Spin_Up_Time 0x0007 130 130 024 Pre-fail - 143 (Average 163)
4 Start_Stop_Count 0x0012 100 100 000 Old_age - 146
5 Reallocated_Sector_Ct 0x0033 100 100 005 Pre-fail - 0
7 Seek_Error_Rate 0x000b 100 100 067 Pre-fail - 0
8 Seek_Time_Performance 0x0005 100 100 020 Pre-fail - 0
9 Power_On_Hours 0x0012 099 099 000 Old_age - 9923
10 Spin_Retry_Count 0x0013 100 100 060 Pre-fail - 0
12 Power_Cycle_Count 0x0032 100 100 000 Old_age - 146
192 Power-Off_Retract_Count 0x0032 100 100 050 Old_age - 529
193 Load_Cycle_Count 0x0012 100 100 050 Old_age - 529
194 Temperature_Celsius 0x0002 134 134 000 Old_age - 41 (Lifetime Min/
Max 11/51)
196 Reallocated_Event_Count 0x0032 100 100 000 Old_age - 0
197 Current_Pending_Sector 0x0022 100 100 000 Old_age - 0
198 Offline_Uncorrectable 0x0008 100 100 000 Old_age - 0
199 UDMA_CRC_Error_Count 0x000a 200 200 000 Old_age - 0
SMART Error Log Version: 1
No Errors Logged
SMART Self-test log, version number 1
No self-tests have been logged
[root@juno shinnai]#
|