Set up SMART Reporting via email

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
The summary table list all the important parameters, if everything is good in this table then the drives should be good ;)

If you want to know exactly what each SMART parameter is then go to the wikipedia page, there's a detailed list of everything.
 

icsy7867

Contributor
Joined
Dec 31, 2015
Messages
167
I have this up and running on 9.3 and it seems to be working great! I went about this a slightly different way though:

I wanted one quick email so I used your second script so it would send a nice and clean "passed" message

My first script does not actually send any emails. I just wanted the shortend output in the files:

Code:
#!/usr/local/bin/sh
#
# Place this in /mnt/pool/scripts
# Call: sh esmart.sh /dev/ada0
# switch1 is the drive to check (passed parameter)
switch1=$1

# This will use the characters after "/dev/" for the temp file names.
# Example: /dev/ada0 becomes coverada0 or cover0ada0 or cover1ada0
# This needs to be done to keep multiple jobs from using the same files.
drv=`echo $switch1 | cut -c6-`

# Variable just so we can add a note that the drive was asleep when the
# application started but is now awake.
c=0

# Process to run our check on the drive
chkdrive()
{
smartctl -H -n standby -l error ${switch1} > /var/cover0${drv}
}



chkdrive
while [ $? != "0" ]
do
# Pause the checking of the drive to about once a minute if the drive is not runni$
  sleep 59
  c=1
  chkdrive
done

if [ $c -eq 1 ]
then
echo "THE DRIVE WAS ASLEEP AND JUST WOKE UP" >> /var/cover${drv}
fi

# These lines remove the automatic Branding lines
sed -e '1d' /var/cover0${drv} > /var/cover1${drv}
sed -e '1d' /var/cover1${drv} > /var/cover0${drv}
sed -e '1d' /var/cover0${drv} > /var/cover1${drv}
sed -e '1d' /var/cover1${drv} > /var/cover0${drv}

cat /var/cover0${drv} >> /var/cover${drv}

#sendmail -t < /var/cover${drv}

# Cleanup our trash
#rm /var/cover${drv}
#rm /var/cover0${drv}
#rm /var/cover1${drv}
exit 0

# Set idle mode to so it doesn't spin up.
# Options
# -n standby (Remove this to force a spinup)
# -i = Device Info
# -H = Device Health
# -A = Only Vendor specific SMART attributes
# -l error = SMART Error Log


I got rid of the email lines at the top, and commented out the file removals. I wanted to grab these, append them to a file, email them, and then delete them.

So in comes my second script, which calls the first script with the correct drives and appends a new file.

Code:
(
echo "To: email@address.net"
echo "Subject: SMART Drive Results for pool"
echo " "
) > /var/results

sh /mnt/Storage/scripts/smart.sh /dev/ada0
sh /mnt/Storage/scripts/smart.sh /dev/ada1
sh /mnt/Storage/scripts/smart.sh /dev/ada2
sh /mnt/Storage/scripts/smart.sh /dev/ada3

echo '/dev/ada0' >> /var/results
cat /var/coverada0 >> /var/results

echo '/dev/ada1' >> /var/results
cat /var/coverada1 >> /var/results

echo '/dev/ada2' >> /var/results
cat /var/coverada2 >> /var/results

echo '/dev/ada3' >> /var/results
cat /var/coverada3 >> /var/results

sendmail -t < /var/results

rm /var/results
find /var/cover* -exec rm -rf {} \;

exit 0



It basically just grabs the coverada# file for the corresponding drives, and appends them to a results file, and then emails that file out instead. There are a lot of these cover* files generated from the first script, and running these separately on the different drives generates them with a variable, I just used the find command to find them all and delete them in one go.

This gives me an email with nice and clear output:

Code:
/dev/ada0
SMART overall-health self-assessment test result: PASSED

SMART Error Log Version: 1
No Errors Logged

/dev/ada1
SMART overall-health self-assessment test result: PASSED

SMART Error Log Version: 1
No Errors Logged

/dev/ada2
SMART overall-health self-assessment test result: PASSED

SMART Error Log Version: 1
No Errors Logged

/dev/ada3
SMART overall-health self-assessment test result: PASSED

SMART Error Log Version: 1
No Errors Logged
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,970
@icsy7867 Glad you are creating your own script modifications. I really like scripts and as you can tell from the first one you listed, I placed a lot of comments in there as to try and explain what is happening each step of the way. Of course you could combine the two scripts if you like, that would be easily done too.
 

fireheadman

Dabbler
Joined
Nov 13, 2016
Messages
49
Was curious if this thread applies to v9.10? And is the first post still the best source given all the updates throughout the thread?
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,970
Was curious if this thread applies to v9.10? And is the first post still the best source given all the updates throughout the thread?
The first posting should have all the updates in it and this should work fine. There are a few postings with other peoples personal preference but that is all. If you find something that doesn't work please let me know and I'll toss you a rope.

You can also find other scripts which do effectively the same thing on the forums, they are just a bit different in the coding of the script and how much detail they desire. I just kept it simple because all I need to know is if it worked or not and if I have a failure, I can troubleshoot as needed should a failure occur.
 

gusgus

Dabbler
Joined
Sep 15, 2014
Messages
13
I can verify that it works without any problems for me on 9.10, even with my custom modifications.
 

RoboKaren

Contributor
Joined
Apr 8, 2014
Messages
130
I have a problem where my SSD reports two temperatures, one incorrect (100C !!), and thus trips a warning. Any thoughts on how to limit the script to looking at just "194 Temperature_Celsius" and skipping "231 Temperature_Celsius"?

FIXED: On a hunch, I edited the script so that:

smartctl -A -i -v 7,hex48 /dev/"$drive" | \

Code:
     smartctl -A -i -v 7,hex48 /dev/"$drive" | \

        awk -v device="$drive" -v tempWarn="$tempWarn" -v tempCrit="$tempCrit" -v sectorsCrit="$sectorsCrit" \

        -v testAgeWarn="$testAgeWarn" -v warnSymbol="$warnSymbol" -v critSymbol="$critSymbol" \

        -v lastTestHours="$(smartctl -l selftest /dev/"$drive" | grep "# 1" | awk '{print $9}')" '\

        /Serial Number:/{serial=$3} \

        /Temperature_Celsius/{temp=$10} \



became:

Code:
        /194 Temperature_Celsius/{temp=$10} \


and it worked.

====





########## SMART status report summary for all drives ##########

+------+---------------+----+-----+-----+-----+-------+-------+--------+------+------+------+-------+----+
|Device|Serial |Temp|Power|Start|Spin |ReAlloc|Current|Offline |UDMA |Seek |High |Command|Last|
| | | |On |Stop |Retry|Sectors|Pending|Uncorrec|CRC |Errors|Fly |Timeout|Test|
| | | |Hours|Count|Count| |Sectors|Sectors |Errors| |Writes|Count |Age |
+------+---------------+----+-----+-----+-----+-------+-------+--------+------+------+------+-------+----+
|ada3 !|FEB407710E08067424xx| 100 | 179| | | | | | | N/A| N/A| N/A| 6|
+------+---------------+----+-----+-----+-----+-------+-------+--------+------+------+------+-------+----+


Here's the full SMART data:




########## SMART status report for ada3 drive :) FEB407710E08067424xx) ##########
smartctl 6.5 2016-05-07 r4318 [FreeBSD 10.3-STABLE amd64] (local build)

SMART overall-health self-assessment test result: PASSED

ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x000b 100 100 050 Pre-fail Always - 0
9 Power_On_Hours 0x0012 100 100 000 Old_age Always - 179
12 Power_Cycle_Count 0x0012 100 100 000 Old_age Always - 12
168 Unknown_Attribute 0x0012 100 100 000 Old_age Always - 0
170 Unknown_Attribute 0x0003 088 088 010 Pre-fail Always - 147
173 Unknown_Attribute 0x0012 100 100 000 Old_age Always - 2
192 Power-Off_Retract_Count 0x0012 100 100 000 Old_age Always - 6
194 Temperature_Celsius 0x0023 067 067 000 Pre-fail Always - 33 (Min/Max 33/33)
218 Unknown_Attribute 0x000b 100 100 050 Pre-fail Always - 0
231 Temperature_Celsius 0x0013 100 100 000 Pre-fail Always - 100
241 Total_LBAs_Written 0x0012 100 100 000 Old_age Always - 7

No Errors Logged

Test_Description Status Remaining LifeTime(hours) LBA_of_first_error
Extended offline Completed without error 00% 44 -
 

toolchain

Cadet
Joined
Jul 13, 2016
Messages
8
Here's a bit modified version for a full SMART daily report that can be configured as a cron task to run daily. I have one of these configured on 3 FreeNAS 9.10 boxes and a FreeNAS 9.3 so everyday when I come in, I expect to get 4 emails with this report being sent by each one of them. I didn't write this script and all credit truly goes to the person who wrote it, although I don't know who that is, I did find this script on this forum and just modified it a bit but am not taking the credit for the hard work of the original author of it.

I set it up to run as root in a cron task to execute this command
Code:
sh /mnt/Pool1/scripts/smartreport.sh

everyday at 7:55am except the weekends.
Here's the modified code:
**If you want to use this code, modify the email line below and the drives lines below accordingly**
Code:

#!/bin/sh
### Parameters ###
logfile="/tmp/smart_report.tmp"
email="youremail@here.com"
subject="Full Detail SMART Status Report"
drives="ada1 ada2 ada3 ada4"
tempWarn=40
tempCrit=45
sectorsCrit=10
testAgeWarn=1
warnSymbol="?"
critSymbol="!"
### Set email headers ###
(
  echo "To: ${email}"
  echo "Subject: ${subject}"
  echo "Content-Type: text/html"
  echo "MIME-Version: 1.0"
  echo -e "\r\n"
) > "$logfile"
### Set email body ###

### CSS Stylesheet ###
(
echo "<html>"
echo "<head>"
echo "<style type "text/css">"
echo "<!--"
echo "/* @group Blink */"
echo ".blink {"
echo "   -webkit-animation: blink .75s linear infinite;"
echo "   -moz-animation: blink .75s linear infinite;"
echo "   -ms-animation: blink .75s linear infinite;"
echo "   -o-animation: blink .75s linear infinite;"
echo "	animation: blink .75s linear infinite;"
echo "}"
echo "@-webkit-keyframes blink {"
echo "   0% { opacity: 1; }"
echo "   50% { opacity: 1; }"
echo "   50.01% { opacity: 0; }"
echo "   100% { opacity: 0; }"
echo "}"
echo "@-moz-keyframes blink {"
echo "   0% { opacity: 1; }"
echo "   50% { opacity: 1; }"
echo "   50.01% { opacity: 0; }"
echo "   100% { opacity: 0; }"
echo "}"
echo "@-ms-keyframes blink {"
echo "   0% { opacity: 1; }"
echo "   50% { opacity: 1; }"
echo "   50.01% { opacity: 0; }"
echo "   100% { opacity: 0; }"
echo "}"
echo "@-o-keyframes blink {"
echo "   0% { opacity: 1; }"
echo "   50% { opacity: 1; }"
echo "   50.01% { opacity: 0; }"
echo "   100% { opacity: 0; }"
echo "}"
echo "@keyframes blink {"
echo "   0% { opacity: 1; }"
echo "   50% { opacity: 1; }"
echo "   50.01% { opacity: 0; }"
echo "   100% { opacity: 0; }"
echo "}"
echo "/* @end */"
echo "-->"
echo "</style>"
echo "</head>"
echo "<body>"
echo "<pre style=\"font-size:14px\">"
) >> "$logfile"
###### summary ######
(
   echo "+------------+"
   echo "|? = <b>Warning</b> |"
   echo "|! = <font color='red' class='blink'>Critical</font>|"
  echo "+------------+"
  echo "========== <b>SMART status report summary for all drives</b> =========="
  echo ""
  echo "+------+---------------+----+-----+-----+-----+-------+-------+--------+------+------+------+-------+----+"
  echo "|Device|Serial  |Temp|Power|Start|Spin |ReAlloc|Current|Offline |UDMA  |Seek  |High  |Command|Last|"
  echo "|  |  |  |On  |Stop |Retry|Sectors|Pending|Uncorrec|CRC  |Errors|Fly  |Timeout|Test|"
  echo "|  |  |  |Hours|Count|Count|  |Sectors|Sectors |Errors|  |Writes|Count  |Age |"
  echo "+------+---------------+----+-----+-----+-----+-------+-------+--------+------+------+------+-------+----+"
) >> "$logfile"
for drive in $drives
do
  (
  smartctl -A -i -v 7,hex48 /dev/"$drive" | \
  awk -v device="$drive" -v tempWarn="$tempWarn" -v tempCrit="$tempCrit" -v sectorsCrit="$sectorsCrit" \
  -v testAgeWarn="$testAgeWarn" -v warnSymbol="$warnSymbol" -v critSymbol="$critSymbol" \
  -v lastTestHours="$(smartctl -l selftest /dev/"$drive" | grep "# 1" | awk '{print $9}')" '\
  /Serial Number:/{serial=$3} \
  /Temperature_Celsius/{temp=$10} \
  /Power_On_Hours/{onHours=$10} \
  /Start_Stop_Count/{startStop=$10} \
  /Spin_Retry_Count/{spinRetry=$10} \
  /Reallocated_Sector/{reAlloc=$10} \
  /Current_Pending_Sector/{pending=$10} \
  /Offline_Uncorrectable/{offlineUnc=$10} \
  /UDMA_CRC_Error_Count/{crcErrors=$10} \
  /Seek_Error_Rate/{seekErrors=("0x" substr($10,3,4));totalSeeks=("0x" substr($10,7))} \
  /High_Fly_Writes/{hiFlyWr=$10} \
  /Command_Timeout/{cmdTimeout=$10} \
  END {
  testAge=sprintf("%.0f", (onHours - lastTestHours) / 24);
  if (temp > tempCrit || reAlloc > sectorsCrit || pending > sectorsCrit || offlineUnc > sectorsCrit)
  device=device " " critSymbol;
  else if (temp > tempWarn || reAlloc > 0 || pending > 0 || offlineUnc > 0 || testAge > testAgeWarn)
  device=device " " warnSymbol;
  seekErrors=sprintf("%d", seekErrors);
  totalSeeks=sprintf("%d", totalSeeks);
  if (totalSeeks == "0") {
  seekErrors="N/A";
  totalSeeks="N/A";
  }
  if (hiFlyWr == "") hiFlyWr="N/A";
  if (cmdTimeout == "") cmdTimeout="N/A";
  printf "|%-6s|%-15s| %s |%5s|%5s|%5s|%7s|%7s|%8s|%6s|%6s|%6s|%7s|%4s|\n",
  device, serial, temp, onHours, startStop, spinRetry, reAlloc, pending, offlineUnc, \
  crcErrors, seekErrors, hiFlyWr, cmdTimeout, testAge;
  }'
  ) >> "$logfile"
done
(
  echo "+------+---------------+----+-----+-----+-----+-------+-------+--------+------+------+------+-------+----+"
  echo ""
  echo ""
) >> "$logfile"
###### for each drive ######
for drive in $drives
do
  brand="$(smartctl -i /dev/"$drive" | grep "Model Family" | awk '{print $3, $4, $5}')"
  serial="$(smartctl -i /dev/"$drive" | grep "Serial Number" | awk '{print $3}')"
  (
  echo ""
  echo "========== <b>SMART status report for ${drive} drive (${brand}: ${serial})</b> =========="
  smartctl -H -A -l error /dev/"$drive"
  smartctl -l selftest /dev/"$drive" | grep "# 1 \|Num" | cut -c6-
  echo ""
  echo ""
  ) >> "$logfile"
done
sed -i '' -e '/smartctl 6.3/d' "$logfile"
sed -i '' -e '/Copyright/d' "$logfile"
sed -i '' -e '/=== START OF READ/d' "$logfile"
sed -i '' -e '/SMART Attributes Data/d' "$logfile"
sed -i '' -e '/Vendor Specific SMART/d' "$logfile"
sed -i '' -e '/SMART Error Log Version/d' "$logfile"
echo "</pre></body></html>" >> "$logfile"
### Send report ###
sendmail -t < "$logfile"
rm "$logfile"




Here is what the email looks like when you receive it.
Code:
+------------+
|? = Warning |
|! = Critical|
+------------+
========== SMART status report summary for all drives ==========

+------+---------------+----+-----+-----+-----+-------+-------+--------+------+------+------+-------+----+
|Device|Serial		 |Temp|Power|Start|Spin |ReAlloc|Current|Offline |UDMA  |Seek  |High  |Command|Last|
|	  |			   |	|On   |Stop |Retry|Sectors|Pending|Uncorrec|CRC   |Errors|Fly   |Timeout|Test|
|	  |			   |	|Hours|Count|Count|	   |Sectors|Sectors |Errors|	  |Writes|Count  |Age |
+------+---------------+----+-----+-----+-----+-------+-------+--------+------+------+------+-------+----+
|ada1 ?|WD-WCC4E6PS9E9E| 30 | 1646|	7|	0|	  0|	  0|	   0|	 0|   N/A|   N/A|	N/A|   8|
|ada2 ?|WD-WCC4E6PS90PA| 32 | 1646|	7|	0|	  0|	  0|	   0|	 0|   N/A|   N/A|	N/A|   8|
|ada3 ?|WD-WCC4E3LTHKRE| 32 | 1646|	7|	0|	  0|	  0|	   0|	 0|   N/A|   N/A|	N/A|   8|
|ada4 ?|WD-WCC4E3AF8473| 31 | 1646|	7|	0|	  0|	  0|	   0|	 0|   N/A|   N/A|	N/A|   8|
+------+---------------+----+-----+-----+-----+-------+-------+--------+------+------+------+-------+----+



========== SMART status report for ada1 drive (Western Digital Red: WD-WCC4E6PS9E9E) ==========
smartctl 6.5 2016-05-07 r4318 [FreeBSD 10.3-STABLE amd64] (local build)

SMART overall-health self-assessment test result: PASSED

ID# ATTRIBUTE_NAME		  FLAG	 VALUE WORST THRESH TYPE	  UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate	 0x002f   200   200   051	Pre-fail  Always	   -	   0
  3 Spin_Up_Time			0x0027   190   189   021	Pre-fail  Always	   -	   7458
  4 Start_Stop_Count		0x0032   100   100   000	Old_age   Always	   -	   7
  5 Reallocated_Sector_Ct   0x0033   200   200   140	Pre-fail  Always	   -	   0
  7 Seek_Error_Rate		 0x002e   200   200   000	Old_age   Always	   -	   0
  9 Power_On_Hours		  0x0032   098   098   000	Old_age   Always	   -	   1646
10 Spin_Retry_Count		0x0032   100   253   000	Old_age   Always	   -	   0
11 Calibration_Retry_Count 0x0032   100   253   000	Old_age   Always	   -	   0
12 Power_Cycle_Count	   0x0032   100   100   000	Old_age   Always	   -	   7
192 Power-Off_Retract_Count 0x0032   200   200   000	Old_age   Always	   -	   2
193 Load_Cycle_Count		0x0032   200   200   000	Old_age   Always	   -	   27
194 Temperature_Celsius	 0x0022   122   117   000	Old_age   Always	   -	   30
196 Reallocated_Event_Count 0x0032   200   200   000	Old_age   Always	   -	   0
197 Current_Pending_Sector  0x0032   200   200   000	Old_age   Always	   -	   0
198 Offline_Uncorrectable   0x0030   100   253   000	Old_age   Offline	  -	   0
199 UDMA_CRC_Error_Count	0x0032   200   200   000	Old_age   Always	   -	   0
200 Multi_Zone_Error_Rate   0x0008   100   253   000	Old_age   Offline	  -	   0

No Errors Logged

Test_Description	Status				  Remaining  LifeTime(hours)  LBA_of_first_error
Short offline	   Completed without error	   00%	  1449		 -



========== SMART status report for ada2 drive (Western Digital Red: WD-WCC4E6PS90PA) ==========
smartctl 6.5 2016-05-07 r4318 [FreeBSD 10.3-STABLE amd64] (local build)

SMART overall-health self-assessment test result: PASSED

ID# ATTRIBUTE_NAME		  FLAG	 VALUE WORST THRESH TYPE	  UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate	 0x002f   200   200   051	Pre-fail  Always	   -	   0
  3 Spin_Up_Time			0x0027   190   189   021	Pre-fail  Always	   -	   7483
  4 Start_Stop_Count		0x0032   100   100   000	Old_age   Always	   -	   7
  5 Reallocated_Sector_Ct   0x0033   200   200   140	Pre-fail  Always	   -	   0
  7 Seek_Error_Rate		 0x002e   200   200   000	Old_age   Always	   -	   0
  9 Power_On_Hours		  0x0032   098   098   000	Old_age   Always	   -	   1646
10 Spin_Retry_Count		0x0032   100   253   000	Old_age   Always	   -	   0
11 Calibration_Retry_Count 0x0032   100   253   000	Old_age   Always	   -	   0
12 Power_Cycle_Count	   0x0032   100   100   000	Old_age   Always	   -	   7
192 Power-Off_Retract_Count 0x0032   200   200   000	Old_age   Always	   -	   2
193 Load_Cycle_Count		0x0032   200   200   000	Old_age   Always	   -	   26
194 Temperature_Celsius	 0x0022   120   116   000	Old_age   Always	   -	   32
196 Reallocated_Event_Count 0x0032   200   200   000	Old_age   Always	   -	   0
197 Current_Pending_Sector  0x0032   200   200   000	Old_age   Always	   -	   0
198 Offline_Uncorrectable   0x0030   100   253   000	Old_age   Offline	  -	   0
199 UDMA_CRC_Error_Count	0x0032   200   200   000	Old_age   Always	   -	   0
200 Multi_Zone_Error_Rate   0x0008   100   253   000	Old_age   Offline	  -	   0

No Errors Logged

Test_Description	Status				  Remaining  LifeTime(hours)  LBA_of_first_error
Short offline	   Completed without error	   00%	  1449		 -



========== SMART status report for ada3 drive (Western Digital Red: WD-WCC4E3LTHKRE) ==========
smartctl 6.5 2016-05-07 r4318 [FreeBSD 10.3-STABLE amd64] (local build)

SMART overall-health self-assessment test result: PASSED

ID# ATTRIBUTE_NAME		  FLAG	 VALUE WORST THRESH TYPE	  UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate	 0x002f   200   200   051	Pre-fail  Always	   -	   0
  3 Spin_Up_Time			0x0027   185   184   021	Pre-fail  Always	   -	   7733
  4 Start_Stop_Count		0x0032   100   100   000	Old_age   Always	   -	   7
  5 Reallocated_Sector_Ct   0x0033   200   200   140	Pre-fail  Always	   -	   0
  7 Seek_Error_Rate		 0x002e   200   200   000	Old_age   Always	   -	   0
  9 Power_On_Hours		  0x0032   098   098   000	Old_age   Always	   -	   1646
10 Spin_Retry_Count		0x0032   100   253   000	Old_age   Always	   -	   0
11 Calibration_Retry_Count 0x0032   100   253   000	Old_age   Always	   -	   0
12 Power_Cycle_Count	   0x0032   100   100   000	Old_age   Always	   -	   7
192 Power-Off_Retract_Count 0x0032   200   200   000	Old_age   Always	   -	   2
193 Load_Cycle_Count		0x0032   200   200   000	Old_age   Always	   -	   27
194 Temperature_Celsius	 0x0022   120   115   000	Old_age   Always	   -	   32
196 Reallocated_Event_Count 0x0032   200   200   000	Old_age   Always	   -	   0
197 Current_Pending_Sector  0x0032   200   200   000	Old_age   Always	   -	   0
198 Offline_Uncorrectable   0x0030   100   253   000	Old_age   Offline	  -	   0
199 UDMA_CRC_Error_Count	0x0032   200   200   000	Old_age   Always	   -	   0
200 Multi_Zone_Error_Rate   0x0008   100   253   000	Old_age   Offline	  -	   0

No Errors Logged

Test_Description	Status				  Remaining  LifeTime(hours)  LBA_of_first_error
Short offline	   Completed without error	   00%	  1449		 -



========== SMART status report for ada4 drive (Western Digital Red: WD-WCC4E3AF8473) ==========
smartctl 6.5 2016-05-07 r4318 [FreeBSD 10.3-STABLE amd64] (local build)

SMART overall-health self-assessment test result: PASSED

ID# ATTRIBUTE_NAME		  FLAG	 VALUE WORST THRESH TYPE	  UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate	 0x002f   200   200   051	Pre-fail  Always	   -	   0
  3 Spin_Up_Time			0x0027   182   181   021	Pre-fail  Always	   -	   7891
  4 Start_Stop_Count		0x0032   100   100   000	Old_age   Always	   -	   7
  5 Reallocated_Sector_Ct   0x0033   200   200   140	Pre-fail  Always	   -	   0
  7 Seek_Error_Rate		 0x002e   200   200   000	Old_age   Always	   -	   0
  9 Power_On_Hours		  0x0032   098   098   000	Old_age   Always	   -	   1646
10 Spin_Retry_Count		0x0032   100   253   000	Old_age   Always	   -	   0
11 Calibration_Retry_Count 0x0032   100   253   000	Old_age   Always	   -	   0
12 Power_Cycle_Count	   0x0032   100   100   000	Old_age   Always	   -	   7
192 Power-Off_Retract_Count 0x0032   200   200   000	Old_age   Always	   -	   2
193 Load_Cycle_Count		0x0032   200   200   000	Old_age   Always	   -	   27
194 Temperature_Celsius	 0x0022   121   116   000	Old_age   Always	   -	   31
196 Reallocated_Event_Count 0x0032   200   200   000	Old_age   Always	   -	   0
197 Current_Pending_Sector  0x0032   200   200   000	Old_age   Always	   -	   0
198 Offline_Uncorrectable   0x0030   100   253   000	Old_age   Offline	  -	   0
199 UDMA_CRC_Error_Count	0x0032   200   200   000	Old_age   Always	   -	   0
200 Multi_Zone_Error_Rate   0x0008   100   253   000	Old_age   Offline	  -	   0

No Errors Logged

Test_Description	Status				  Remaining  LifeTime(hours)  LBA_of_first_error
Short offline	   Completed without error	   00%	  1449		 -


 

Bullseye2267

Cadet
Joined
Aug 2, 2017
Messages
1
Is there a way to add color to the output like "Passed" is in green & "Fail" is in red? Maybe Drive life remaining time 50%-75% in yellow & 76%+ in red. Stuff like that.

Edit...
Oh, maybe you did.
 

Ramboxman

Explorer
Joined
Jun 20, 2013
Messages
63
I setup rules in apple mail to color code my emails, but nothing for passed or failed. Last two email for system temps where much higher, so I went to see if case was dusty and I had a case fan go out. Easy swap, and lucky I caught this early. SMART never sent anything out so glad I set this up.
 

bhoriss

Dabbler
Joined
Nov 25, 2016
Messages
11
Hi,
I am a big FreeNas and Linux newb.
I am running FreeNas 11.0 and want to verify that my SMART reporting via email works.
I planned on using your scrip to do this.

I am running into a problem at the very beginning of your tutorial

When I "cd /mnt/pool"
i get

Code:
/mnt/pool: No such file or directory.


As you may imagine, I feel quite newbish as I can't even pass step 2 of a very very long post... :(

any help?

This is a simple way to get SMART monitoring to report daily the status of your hard drives.

The purpose of this is to have all your SMART enabled drives report how they are doing daily. I wanted to see how many times the drives spun up and down, see if there were any flaky transmission errors because I had a bad SATA cable and it was detected through SMART.

EIDT 13 JAN 2016: Here is a link to a nice collection of scripts which expand on what this thread did. I highly recommend you check this out.

EDIT (9 OCT 2015): I didn't give this script much though when it came to implementing it and I really should have taken a better approach but you know hindsight, she's a real ... So I have made some changes below to correct this oversight on my part. The change deals with where the script resides and I have moved it from the boot device to a directory located at "/mnt/pool/scripts" and you can change this of course to your liking.

EDIT (11 November 2015): Fix typo in step 14.

This code is not persistent between upgrades of FreeNAS and must be placed back on the boot drive. You can run this from one of your hard drives however it will force them to spin up each time and you may not desire that.

This is a very simple script and implementing it will take very little time.

First the basic instructions:
NOTE: Do not type the single quotes, they are simply around the text to type. It is assumed you already have FreeNAS email all set up. Sendmail will fail if it is not set up. And "pool" is the name of your pool so change it as appropriate.

1) SSH or use the console and log in as root/SU.

2) Type 'mount -wu /'

2) Type 'cd /conf/base/etc' 'cd /mnt/pool'
 

Wolfeman0101

Patron
Joined
Jun 14, 2012
Messages
428
Hi,
I am a big FreeNas and Linux newb.
I am running FreeNas 11.0 and want to verify that my SMART reporting via email works.
I planned on using your scrip to do this.

I am running into a problem at the very beginning of your tutorial

When I "cd /mnt/pool"
i get

Code:
/mnt/pool: No such file or directory.


As you may imagine, I feel quite newbish as I can't even pass step 2 of a very very long post... :(

any help?
"pool" is the name of your zpool. Mine is vol1. You want to cd /mnt/your_pool_name.
 

bhoriss

Dabbler
Joined
Nov 25, 2016
Messages
11
"pool" is the name of your zpool. Mine is vol1. You want to cd /mnt/your_pool_name.
Yes, of course it wasn't written 3 lines over step 2, wasn't underlined and I didn't expect it to only need to be changed in the script and humiliated myself....

Imma hide under a rock and get back to scripting when I'm less tired.

Thanks for the very quick response.

Bhoriss
 

Wolfeman0101

Patron
Joined
Jun 14, 2012
Messages
428
Yes, of course it wasn't written 3 lines over step 2, wasn't underlined and I didn't expect it to only need to be changed in the script and humiliated myself....

Imma hide under a rock and get back to scripting when I'm less tired.

Thanks for the very quick response.

Bhoriss
No worries. Never be afraid to ask. We were all new to this at one point.
 

thefox13

Dabbler
Joined
Sep 15, 2014
Messages
21
Hey guys,
It's been awhile but I am having the the worst luck getting the basic script to run under U4. I've ended up commenting most of the email script out to try to debug what is going on, any thoughts would be appreciated!

smartctl errors out with:
: unable to detect device type.
Please specify device type with the -d option.

exit: Illegal number: 0

I ran it from my scripts folder created via the first post. I has to be somethink incredibly simple I'm overlooking. I can run the same smartdtl command from shell without an issue. Just doesn't work when I run the script.

#!/usr/local/bin/sh
#
# Place this in /mnt/pool/scripts
# Call: sh esmart.sh /dev/ada0
switch1=$1
#(
#echo "To: YourEmail@Address.net"
#echo "Subject: SMART Drive Results for ${switch1}"
#echo " "
#) > /var/cover
smartctl -i -H -A -n standby -l error ${switch1} #>> /var/cover
#sendmail -t < /var/cover
exit 0
 

anmnz

Patron
Joined
Feb 17, 2018
Messages
286

thefox13

Dabbler
Joined
Sep 15, 2014
Messages
21
HA!
That was it, although I tried to edit it via nano in shell but that did not seem to work.
What worked was Notepad++.
For anyone else, you can copy the code into Notepad++ and go to Edit -> EOL Conversion -> Unix (LF)
Save that file to your server, point the CRON job to it, and voila!
 

suf1xx

Cadet
Joined
May 19, 2019
Messages
1
Hey All, I am having an issue with the top part of the report. It comes up all blank. see attached.

Rest of the report comes in fine, all the drives and all the details are ok.
 

Attachments

  • smart report.png
    smart report.png
    13 KB · Views: 833
Top