smartd

最後更新: 2015-06-18

安裝

# Debian

apt-get install smartmontools

# Centos

yum install smartmontools

提供

  • /usr/sbin/smartd
  • /usr/sbin/smartctl

Scripts

  • /etc/init.d/smartmontools
  • /etc/init.d/smartd

* Default 只有 /etc/rc2.d/S04smartmontools

主程式

/usr/sbin/smartd

 


開機時啟動:

/etc/default/smartmontools

# List of devices you want to explicitly enable S.M.A.R.T.
enable_smart="/dev/sda /dev/sdb"

# start smartd on system startup
start_smartd=yes

# Sets the interval between disk checks to N seconds
smartd_opts="--interval=1800"

它會影響以 /etc/init.d/smartmontools 的啟動, 原因

[ -r /etc/default/smartmontools ] && . /etc/default/smartmontools

 


smartd 的主設定檔

 

/etc/smartd.conf

# 全自動設定
# cause any remaining lines in this configuration file to be ignored
# it tells smartd to scan for all ATA and SCSI devices
# smartd will scan for devices /dev/hd[a-l] and /dev/sd[a-z]
DEVICESCAN -d removable -n standby -m root -M exec /usr/share/smartmontools/smartd-runner

# continue lines '\'

# Ignore temperature(194) and power-on hours(9)
# -I ID   Ignore Attribute ID (-p | -u :  "Prefailure | Usage" Normalized Attributes)
# "-I 194 -I 9"

# USB Disk
# If a SCSI to ATA Translation (SAT) layer is between the OS and the device
# /dev/sda -a -d sat

# 最簡單的設定 (Only report SMART health status if it fails)
#   -C ID   Report if Current Pending Sector count non-zero ( 197 )
#   -U ID   Report if Offline Uncorrectable count non-zero ( 198 )
#   -H      Monitor SMART Health Status, report if failed
# -m ADD    Send warning email to "ADD" for -H, -l error, -l selftest, and -f
#/dev/hdc -H -C 0 -U 0 -m admin@example.com

# raw temperature changes >= 5 Celsius
# -W D,I,C   # Monitor Temperature D)ifference, I)nformal limit, C)ritical limit
#DEVICESCAN -I 194 -I 9 -W 5

# 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.
# -a      Default: equivalent to -H -f -t -l error -l selftest -C 197 -U 198
# -C ID   Report if Current Pending Sector count non-zero
# -U ID   Report if Offline Uncorrectable count non-zero
# -R ID   Track changes in Attribute ID Raw value with -p, -u or -t
#/dev/hdc -a -I 194 -W 4,45,55 -R 5 -m admin@example.com

# re-read configure file

killall -s HUP smartd

 


Example Mail

 

This email was generated by the smartd daemon running on:

   host name: server
  DNS domain: local
  NIS domain: (none)

The following warning/error was logged by the smartd daemon:

Device: /dev/sda [SAT], Temperature 37 Celsius reached critical limit of 35 Celsius (Min/Max ??/37)


For details see host's SYSLOG.

You can also use the smartctl utility for further investigation.
Another email message will be sent in 24 hours if the problem persists.

 


Range

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.

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.
                                        
                                        
# First (primary) ATA/IDE hard disk.  Monitor all attributes, enable
# automatic online data collection, automatic Attribute autosave, and
# start a short self-test every day between 2-3am, and a long self test
# Saturdays between 3-4am.
#   -o VAL  Enable/disable automatic offline tests (on/off)
#   -S VAL  Enable/disable attribute autosave (on/off)
#   -s REGE Start self-test when type/date matches regular expression (see man page)
# To schedule a short Self-Test between 2-3am every morning, use:
#               -s S/../.././02
# To schedule a long Self-Test between 4-5am every Sunday morning, use:
#               -s L/../../7/04
#/dev/hda -a -o on -S on -s (S/../.././02|L/../../6/03)

 


Testing

ps aux | grep smartd

/usr/sbin/smartd --pidfile /var/run/smartd.pid

 

 


另外參考

 

http://datahunter.org/smartmontools