Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Cron job script' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Cron job script
Authored by: allanmarcus on Mar 17, '04 11:07:32AM
This script should test all your attached drives.

#!/bin/sh

# 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

# 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 "***DANGER WILL ROBINSON***"
	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
exit $WARNING[</code]


[ Reply to This | # ]