Title: smart.sh.2016.04.04 \\ Created: 2018-04-29 22:29:16 +0000 \\ #!/bin/bash # Script to test SMART status of mounted drives # By Allan Marcus # Los Alamos National Laboratory # 2004-02-25 # This script and its contents are placed in the public domain by the author # clear the screen clear # info for user echo "`tput rev`STORAGE DRIVE SMART STAUTS REPORT`tput sgr0`" echo echo "Hard drive/SSD self-reporting health status. . ." echo # First get the list of devices DISKS=($(diskutil list | grep ^\/)) # Set a warning flag to 0 - everything OK # will be set to 1 if there is a problem later WARNING=0 # If you want to do something if there is a reported problem # then do it here. # Note that mail (sendmail) is not set up to send mail by # default on a Mac, so you can't just use "mail" on_warning() { echo "`tput rev`***WARNING***`tput sgr0`" echo "A SMART problem was reported with $1" echo } # now loop through each device and test to see if it's SMART enabled, # and verified for ((index=0 ; index < ${#DISKS[*]} ; index++ )) do echo echo "Results for ${DISKS[index]}" df -h | grep ${DISKS[index]} RESULT=$(diskutil info ${DISKS[index]} | grep "SMART Status") if [ $? == 0 ]; then echo " $RESULT" if ! echo $RESULT | grep -q Verified ; then # set the warning for the exit status on_warning ${DISKS[index]} WARNING=1 fi else echo " SMART not supported on this device " echo " (generally only supported on IDE hard drives)" fi done echo echo -n "Press Return when done reading results:" read RETURN echo #exit $WARNING