SMART Monitoring Tools Setup
Overview: “smartmontools” is a control and monitor utility for SMART (Self-Monitoring, Analysis, and Reporting Technology) Disks. Using this module, which is built into many modern storage devices, one may monitor, store, and analyze the health of a drive(s). This is a write-up on how to install the tool, configure the tool’s daemon, and schedule a script for tailored reports.
Configuration
Install SMART Monitoring tool on your Operating System (OS) via your package manager if it’s not already installed:
(package manager name) install smartmontools
Edit the configuration file (/etc/smartd.conf) for the SMART daemon to reflect your needs. If you do nothing, the SMART daemon will scan the health status of all ATA and SCSI devices, and email “root” with a report. This can prove unwieldy, and you may comment out this line:
# DEVICESCAN -H -m root
to disable the default action and set your own directives. Here’s a sample directive:
### For reference ###
# T/MM/DD/d/HH
# T = test type {L = long; S = short}
# MM = month (01..12)
# DD = day of the month (1..31)
# d = day of week (1[Mon]..7[Sun])
# HH = hour of the day (00-23)
### 28 Aug 2021 (@nyu.edu) ###
# For the following drives:
# monitor -a (all) SMART errors
# enable -o (offline) data collection
# on the follwing -s (schedule)
# 02:00
# run a short (s) test on the 1st of each month
# run a (l) test on the 15th of each month
/dev/sda -a -o -s (S/../1/./02|L/../15/./02)
/dev/sdb -a -o -s (S/../1/./02|L/../15/./02)
Check the status of the SMART daemon:
service status smartd or systemctl status smartmontool
Start the SMART daemon:
service start smartd or systemctl start smartmontool
Check the chkconfig (startup) status of the SMART daemon:
chkonfig --list smartd or update-rc.d smartmontools enable
Enable the SMART daemon to run on startup:
chkconfig smartd on or sudo update-rc.d smartmontools enable or
sudo update-rc.d smartmontools enable
Here’s our monitoring script:
https://gist.github.com/marshki/78e31b1219c08983ba7a8fe00303217f
It needs to run as root, so:
get root’s PATH:
echo $PATH
and place it under the shebang (#!/usr/bin/env bash) in the script.
Next, place the script in:
/usr/local/sbin/
Set permissions on the file:
chmod 700 /usr/local/sbin/smarty_pants.sh
Add a cron job to call this script:
crontab -e
00 05 * * 1 /root/scripts/smarty_pants.sh
Sample Output:
(Pass)
SMART report for: nyu.edu@Aug 30 01:24:01 PM
----------
SMART status: No problems detected on: /dev/sda.
Model Family: Seagate Constellation ES.2 (SATA 6Gb/s)
Device Model: ST33000650NS
Serial Number: Z292F334
User Capacity: 3,000,592,982,016 bytes [3.00 TB]
----------
SMART status: No problems detected on: /dev/sdb.
Model Family: Seagate Constellation ES.2 (SATA 6Gb/s)
Device Model: ST33000650NS
Serial Number: Z292BG3W
User Capacity: 3,000,592,982,016 bytes [3.00 TB]
(Fail)
SMART report for: nyu.edu@Aug 25 11:56:21
----------
SMART status:---WARNING!!!---501 bad sectors detected on: /dev/sda!!!
Model Family: Seagate Constellation ES.2 (SATA 6Gb/s)
Device Model: ST33000650NS
Serial Number: Z2910EQX
User Capacity: 3,000,592,982,016 bytes [3.00 TB]
----------
SMART status: No problems detected on: /dev/sdb.
Model Family: Seagate Constellation ES.2 (SATA 6Gb/s)
Device Model: ST33000650NS
Serial Number: Z290WYWP
User Capacity: 3,000,592,982,016 bytes [3.00 TB]