(*
Script to test SMART status of mounted disk drives.
By: Joe Szedula
Notes:
- Double-clicking on this script will check the SMART status but only display a dialog box if it detects a problem.
This makes it a good candiate for a startup item.
- Draging anything (file, folder, disk) to the script's icon will cause it to perform the SMART status checks and display all results.
*)
global showResults
on run
set showResults to false
CheckSMART()
end run
on open (theList)
set showResults to true
CheckSMART()
end open
on CheckSMART()
set out to "SMART Status:"
do shell script "diskutil list | grep /dev/"
set theDisks to paragraphs of result as list
tell application "Finder"
-- get a list of all mounted volumes
set volumes to name of every disk as list
set maxLength to 0
repeat with vol in volumes
set vol to vol as text
set n to count of character in vol
if n > maxLength then set maxLength to n
end repeat
set maxLength to maxLength + 1
repeat with theDisk in theDisks
set theDisk to theDisk as text
set cmd to "diskutil list " & theDisk & " | grep Apple_HFS"
set theResult to do shell script cmd
repeat with p in paragraphs of theResult
set p to p as text
set n to count of words in p
set theDisk to last word of p
set vol to ""
repeat with i from 5 to (n - 3)
if vol is not equal to "" then set vol to vol & " "
set vol to vol & (word i of p)
end repeat
set vol to vol & ": "
set n to count of character in vol
repeat with i from 1 to (maxLength - n)
set vol to vol & " "
end repeat
set cmd to "diskutil info /dev/" & theDisk & " | grep 'SMART Status' | sed -e 's/ SMART Status: //'"
set theResult to do shell script cmd
if theResult is equal to "Verified" then
else if theResult is equal to "Not Supported" then
else
set showResults to true
end if
set out to out & return & " " & vol & " " & theResult
end repeat
end repeat
end tell
if showResults then
activate
display dialog out buttons {"Ok"} default button 1
end if
end CheckSMART