July 15, 2015

Monitoring hard disks and alerting on errors with smartmontools on Linux

Filed under: Technical — Tags: , — James Bunton @ 12:00 am

A simple configuration to regular check all local disks for errors. Any problems will go to syslog/journald as well as being emailed to root.

Make sure you have an MTA installed. I use ssmtp.

Install the smartmontools package and configure it as follows.

/etc/smartd.conf

# /etc/smartd.conf
# See the manual for smartd.conf
# 1) Scan for all devices (DEVICESCAN)
# 2) Check the SMART health status (-H)
# 3) Report increases in SMART error logs (-l)
# 4) Check for failure of any Usage Attributes (-f)
# 5) Run an Offline Immediate Test every six hours (O/../.././(00|06|12|18))
# 6) Run a Short Self-Test every day at 0100 (S/../.././01)
# 7) Run a Long Self-Test every Saturday at 0300 (L/../../6/03)
# 8) Report any output by running scripts in /etc/smartmontools/run.d

DEVICESCAN -H -l error -l selftest -f -s (O/../.././(00|06|12|18)|S/../.././01|L/../../6/03) -m root -M exec /usr/share/smartmontools/smartd-runner