「Smartmontools」在Linux當中可以透過yum來安裝即可,我要安裝的同時才發現我系統內原本就有這個套件,之前都沒有用到還真是小小浪費了~來看看除了文件檔之外有哪些檔案呢?
$ rpm -ql smartmontools
/etc/rc.d/init.d/smartd
/etc/smartd.conf
/etc/sysconfig/smartmontools
/usr/sbin/smartctl
/usr/sbin/smartd
/etc/rc.d/init.d/smartd
/etc/smartd.conf
/etc/sysconfig/smartmontools
/usr/sbin/smartctl
/usr/sbin/smartd
原來這工具就是系統內一直都沒開啟使用的「smartd」服務啊^^a,一直以來我都沒有開啟過,一直以來都只開起【必要開啟的服務】,其他的能省則省。
$ smartctl -a /dev/sdb3
smartctl version 5.38 [i686-redhat-linux-gnu] Copyright (C) 2002-8 Bruce Allen
Home page is http://smartmontools.sourceforge.net/
=== START OF INFORMATION SECTION ===
Device Model: ST31000333AS
Serial Number: 9TE10MBY
Firmware Version: CC1H
User Capacity: 1,000,203,804,160 bytes
Device is: Not in smartctl database [for details use: -P showall]
ATA Version is: 8
ATA Standard is: ATA-8-ACS revision 4
Local Time is: Tue Feb 8 14:25:49 2011 CST
SMART support is: Available - device has SMART capability.
SMART support is: Disabled(未啟動HDD SMART)
SMART Disabled. Use option -s with argument 'on' to enable it.(未啟動服務)
啟動服務後就會有一堆硬碟資訊出現了~
smartctl version 5.38 [i686-redhat-linux-gnu] Copyright (C) 2002-8 Bruce Allen
Home page is http://smartmontools.sourceforge.net/
=== START OF INFORMATION SECTION ===
Device Model: ST31000333AS
Serial Number: 9TE10MBY
Firmware Version: CC1H
User Capacity: 1,000,203,804,160 bytes
Device is: Not in smartctl database [for details use: -P showall]
ATA Version is: 8
ATA Standard is: ATA-8-ACS revision 4
Local Time is: Tue Feb 8 14:25:49 2011 CST
SMART support is: Available - device has SMART capability.
SMART support is: Disabled(未啟動HDD SMART)
SMART Disabled. Use option -s with argument 'on' to enable it.(未啟動服務)
啟動服務後就會有一堆硬碟資訊出現了~
=== 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:
Offline data collection status: (0x82) Offline data collection activity
was completed without error.
Auto Offline Data Collection: Enabled.
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: ( 625) seconds.
Offline data collection
capabilities: (0x7b) SMART execute Offline immediate.
Auto Offline data collection on/off support.
Suspend Offline collection upon new
command.
Offline surface scan supported.
Self-test supported.
Conveyance Self-test supported.
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: ( 212) minutes.
Conveyance self-test routine
recommended polling time: ( 2) minutes.
SCT capabilities: (0x103f) SCT Status supported.
SCT Feature Control supported.
SCT Data Table supported.
SMART Attributes Data Structure revision number: 10
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE
資訊真的是多到眼花撩亂,若不是有特殊的監控項目,還真的不知道該如何著手,而且我的Linux是架設在ESXi上,系統的硬碟其實是看不到SMART的資訊,自己【Mapping Physical Disk to vmdk】的硬碟才可以看的到SMART的訊息,ESXi的硬碟可能還是得從ESXi的方面著手。而我主要要觀察的項目為溫度,在上方資訊要觀察的項目是194這個項次。
自己下指令或是寫script觀察溫度是可行的,不過既然smartd是一個服務,不妨看看設定檔,果然有監控的選項即設定,當發生問題時可以主動發信告知,也可以將一些紀錄寫入syslog,日後有需要查詢時也方便許多。仔細查看/etc/smartd.conf的設定檔,發現可以監控的項目不少,而且預設的範例都有寫在設定檔內,若有一些進階需求,可以翻翻設定檔或許會有解答,而我目前只改了一些基本的設定。
# 全域設定寄發郵件的對象
DEVICESCAN -H -m 電子信箱
# 每小時紀錄194、231、9的訊息到syslog
DEVICESCAN -I 194 -I 231 -I 9
# Monitor all attributes except normalized Temperature (usually 194),
# but track Temperature changes >= 4 Celsius, report Temperatures
# >= 45 Celsius and changes in Raw value of Reallocated_Sector_Ct (5).
# Send mail on SMART failures or when Temperature is >= 55 Celsius.
# 應該是溫度改變超過4度,溫度大於45、55度告警,以及磁區故障系統自動配置備用磁區超過5時告警
/dev/sdb -a -I 194 -W 4,45,55 -R 5 -m 電子信箱
# 默默的檢查,SMART發生異常時才發出通知
/dev/sdb -H -C 0 -U 0 -m 電子信箱
# 更多的設定選項如下
-d TYPE Set the device type: ata, scsi, marvell, removable, 3ware,N, hpt,L/M/N
-T TYPE set the tolerance to one of: normal, permissive
-o VAL Enable/disable automatic offline tests (on/off)
-S VAL Enable/disable attribute autosave (on/off)
-n MODE No check. MODE is one of: never, sleep, standby, idle
-H Monitor SMART Health Status, report if failed
-l TYPE Monitor SMART log. Type is one of: error, selftest
-f Monitor for failure of any 'Usage' Attributes
-m ADD Send warning email to ADD for -H, -l error, -l selftest, and -f
-M TYPE Modify email warning behavior (see man page)
-s REGE Start self-test when type/date matches regular expression (see man page)
-p Report changes in 'Prefailure' Normalized Attributes
-u Report changes in 'Usage' Normalized Attributes
-t Equivalent to -p and -u Directives
-r ID Also report Raw values of Attribute ID with -p, -u or -t
-R ID Track changes in Attribute ID Raw value with -p, -u or -t
-i ID Ignore Attribute ID for -f Directive
-I ID Ignore Attribute ID for -p, -u or -t Directive
-C ID Report if Current Pending Sector count non-zero
-U ID Report if Offline Uncorrectable count non-zero
-W D,I,C Monitor Temperature D)ifference, I)nformal limit, C)ritical limit
-v N,ST Modifies labeling of Attribute N (see man page)
-a Default: equivalent to -H -f -t -l error -l selftest -C 197 -U 198
-F TYPE Use firmware bug workaround. Type is one of: none, samsung
-P TYPE Drive-specific presets: use, ignore, show, showall
DEVICESCAN -H -m 電子信箱
# 每小時紀錄194、231、9的訊息到syslog
DEVICESCAN -I 194 -I 231 -I 9
# Monitor all attributes except normalized Temperature (usually 194),
# but track Temperature changes >= 4 Celsius, report Temperatures
# >= 45 Celsius and changes in Raw value of Reallocated_Sector_Ct (5).
# Send mail on SMART failures or when Temperature is >= 55 Celsius.
# 應該是溫度改變超過4度,溫度大於45、55度告警,以及磁區故障系統自動配置備用磁區超過5時告警
/dev/sdb -a -I 194 -W 4,45,55 -R 5 -m 電子信箱
# 默默的檢查,SMART發生異常時才發出通知
/dev/sdb -H -C 0 -U 0 -m 電子信箱
# 更多的設定選項如下
-d TYPE Set the device type: ata, scsi, marvell, removable, 3ware,N, hpt,L/M/N
-T TYPE set the tolerance to one of: normal, permissive
-o VAL Enable/disable automatic offline tests (on/off)
-S VAL Enable/disable attribute autosave (on/off)
-n MODE No check. MODE is one of: never, sleep, standby, idle
-H Monitor SMART Health Status, report if failed
-l TYPE Monitor SMART log. Type is one of: error, selftest
-f Monitor for failure of any 'Usage' Attributes
-m ADD Send warning email to ADD for -H, -l error, -l selftest, and -f
-M TYPE Modify email warning behavior (see man page)
-s REGE Start self-test when type/date matches regular expression (see man page)
-p Report changes in 'Prefailure' Normalized Attributes
-u Report changes in 'Usage' Normalized Attributes
-t Equivalent to -p and -u Directives
-r ID Also report Raw values of Attribute ID with -p, -u or -t
-R ID Track changes in Attribute ID Raw value with -p, -u or -t
-i ID Ignore Attribute ID for -f Directive
-I ID Ignore Attribute ID for -p, -u or -t Directive
-C ID Report if Current Pending Sector count non-zero
-U ID Report if Offline Uncorrectable count non-zero
-W D,I,C Monitor Temperature D)ifference, I)nformal limit, C)ritical limit
-v N,ST Modifies labeling of Attribute N (see man page)
-a Default: equivalent to -H -f -t -l error -l selftest -C 197 -U 198
-F TYPE Use firmware bug workaround. Type is one of: none, samsung
-P TYPE Drive-specific presets: use, ignore, show, showall
大致上我就只有設定那麼一些些,主要還是藉由服務幫忙監控,若是需要更簡單的方式監控硬碟溫度,可以設定「hddtemp」的服務,不過能偵測的硬碟有限,snmp的資訊似乎也沒溫度的相關訊息,所以暫時就是簡單的設定告警囉!
http://smartmontools.sourceforge.net/