Scripts to report SMART, ZPool and UPS status, HDD/CPU T°, HDD identification and backup the config

zoomzoom

Guru
Joined
Sep 6, 2015
Messages
677
Even with empty fields, the output should still be aligned.
  • To get it aligned when pasting into code, copy the output first to a notepad program, and convert all tabs to 4 spaces
@GBillR In regards to ada0, you're likely going to need to do one of three things, as SSDs don't report S.M.A.R.T data values the same way HDDs do (or more accurately, they don't use the same line values):
  1. Easiest ways:
    1. Specify each drive in the drive variable, excluding ada0
      OR
    2. Simply add white spaces to the script for the power on hours column, which would correct that columns misalignment for ada0
    OR
  2. More difficult: play around with smartctl with ada0, or do some research on google to determine what S.M.A.R.T values the drive will report and what lines those equate to, then:
    1. Modify the script, moving ada0 to it's own variable, then add a new command bracket below the current one for the new variable containing ada0, adjusting the data that is polled accordingly to remove the power on hours value from being grabbed
End result would look something like:
ada6 is an SSD
Code:
								   ##-----> S.M.A.R.T Status Summary <-----##

+------+---------------+----+-----+-----+-----+-------+-------+--------+------+------+------+-------+----+
|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 |
+------+---------------+----+-----+-----+-----+-------+-------+--------+------+------+------+-------+----+
|ada0  |Z30xxxKC	   | 32 | 9700| 2039|	0|	  0|	  0|	   0|	 0|	 0|	 0|	  6|   0|
|ada1  |Z30xxxKA	   | 31 | 6199|   42|	0|	  0|	  0|	   0|	 0|	 0|	 0|	  0|   0|
|ada2  |Z30xxxYL	   | 30 | 9698| 2039|	0|	  0|	  0|	   0|	 0|	 0|	 0|	 13|   3|
|ada3  |Z30xxxG7	   | 28 | 6224|   43|	0|	  0|	  0|	   0|	 0|	 0|	 0|	  0|   0|
|ada4  |Z30xxxQC	   | 33 | 6176|   41|	0|	  0|	  0|	   0|	 0|	 0|	 0|	  0|   3|
|ada5  |Z30xxxJ7	   | 35 | 9699| 2087|	0|	  0|	  0|	   0|	 0|	 0|	 0|	  4|   3|
|ada6  |S21TNxxxxxxxx9R| 00 |	 |	 |	 |	  0|	   |		|	  |   N/A|   N/A|	N/A|   8|
|ada7  |JR10004M1xxxLF | 24 | 6600|   32|	0|	  0|	  0|	   0|	 0|   N/A|   N/A|	N/A|   3|
|ada8  |JR10004M1xxxAF | 24 | 6600|   32|	0|	  0|	  0|	   0|	 0|   N/A|   N/A|	N/A|   3|
|ada9  |JR10004M1xxx8F | 25 | 6600|   33|	0|	  0|	  0|	   0|	 0|   N/A|   N/A|	N/A|   3|
|ada10 |Z30xxxEF	   | 36 | 9815| 2077|	0|	  0|	  0|	   0|	 0|	 0|	 0|	  4|   3|
|ada11 |S30xxx3D	   | 34 |11100|11977|	0|	  0|	  0|	   0|	 0|	 0|	 0|	 11|   0|
|da0   |			   | 00 |	 |	 |	 |	   |	   |		|	  |   N/A|   N/A|	N/A|   0|
|da1   |			   | 00 |	 |	 |	 |	   |	   |		|	  |   N/A|   N/A|	N/A|   0|
|da2   |			   | 00 |	 |	 |	 |	   |	   |		|	  |   N/A|   N/A|	N/A|   0|
|da3   |			   | 00 |	 |	 |	 |	   |	   |		|	  |   N/A|   N/A|	N/A|   0|
|da4   |			   | 00 |	 |	 |	 |	   |	   |		|	  |   N/A|   N/A|	N/A|   0|
|da5   |			   | 00 |	 |	 |	 |	   |	   |		|	  |   N/A|   N/A|	N/A|   0|
|da6   |			   | 00 |	 |	 |	 |	   |	   |		|	  |   N/A|   N/A|	N/A|   0|
+------+---------------+----+-----+-----+-----+-------+-------+--------+------+------+------+-------+----+

OR
  • Change variable: drives="ada0 ada1 ada2 ada3 ada4 ada5 ada7 ada8 ada9 ada10 ada11 da0 da1 da2 da3 da4 da5 da6", which would then look like:
Code:
								   ##-----> S.M.A.R.T Status Summary <-----##

+------+---------------+----+-----+-----+-----+-------+-------+--------+------+------+------+-------+----+
|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 |
+------+---------------+----+-----+-----+-----+-------+-------+--------+------+------+------+-------+----+
|ada0  |Z30xxxKC	   | 32 | 9700| 2039|	0|	  0|	  0|	   0|	 0|	 0|	 0|	  6|   0|
|ada1  |Z30xxxKA	   | 31 | 6199|   42|	0|	  0|	  0|	   0|	 0|	 0|	 0|	  0|   0|
|ada2  |Z30xxxYL	   | 30 | 9698| 2039|	0|	  0|	  0|	   0|	 0|	 0|	 0|	 13|   3|
|ada3  |Z30xxxG7	   | 28 | 6224|   43|	0|	  0|	  0|	   0|	 0|	 0|	 0|	  0|   0|
|ada4  |Z30xxxQC	   | 33 | 6176|   41|	0|	  0|	  0|	   0|	 0|	 0|	 0|	  0|   3|
|ada5  |Z30xxxJ7	   | 35 | 9699| 2087|	0|	  0|	  0|	   0|	 0|	 0|	 0|	  4|   3|
|ada7  |JR10004M1xxxLF | 24 | 6600|   32|	0|	  0|	  0|	   0|	 0|   N/A|   N/A|	N/A|   3|
|ada8  |JR10004M1xxxAF | 24 | 6600|   32|	0|	  0|	  0|	   0|	 0|   N/A|   N/A|	N/A|   3|
|ada9  |JR10004M1xxx8F | 25 | 6600|   33|	0|	  0|	  0|	   0|	 0|   N/A|   N/A|	N/A|   3|
|ada10 |Z30xxxEF	   | 36 | 9815| 2077|	0|	  0|	  0|	   0|	 0|	 0|	 0|	  4|   3|
|ada11 |S30xxx3D	   | 34 |11100|11977|	0|	  0|	  0|	   0|	 0|	 0|	 0|	 11|   0|
|da0   |			   | 00 |	 |	 |	 |	   |	   |		|	  |   N/A|   N/A|	N/A|   0|
|da1   |			   | 00 |	 |	 |	 |	   |	   |		|	  |   N/A|   N/A|	N/A|   0|
|da2   |			   | 00 |	 |	 |	 |	   |	   |		|	  |   N/A|   N/A|	N/A|   0|
|da3   |			   | 00 |	 |	 |	 |	   |	   |		|	  |   N/A|   N/A|	N/A|   0|
|da4   |			   | 00 |	 |	 |	 |	   |	   |		|	  |   N/A|   N/A|	N/A|   0|
|da5   |			   | 00 |	 |	 |	 |	   |	   |		|	  |   N/A|   N/A|	N/A|   0|
|da6   |			   | 00 |	 |	 |	 |	   |	   |		|	  |   N/A|   N/A|	N/A|   0|
+------+---------------+----+-----+-----+-----+-------+-------+--------+------+------+------+-------+----+
 
Last edited:

GBillR

Contributor
Joined
Jun 12, 2016
Messages
189
To get it aligned when pasting into code, copy the output first to a notepad program, and convert all tabs to 4 spaces

Thank you!

Specify each drive in the drive variable

That is the approach I have taken for now. I really liked the idea of have the script recognize my drives automatically since I intend to add more storage soon, but it may be simply too much work for the desired result. I can simply modify it after I add the additional drives.

Play around with smartctl with ada0, or do some research on google to determine what S.M.A.R.T values the drive will report and what lines those equate to, then:
  1. Modify the script, moving ada0 to it's own variable
  2. Then, add a new command bracket below the current one for the new variable containing ada0, adjusting the data that is polled accordingly to remove the power on hours value from being grabbed

I intend to take a look at this and see what the value add would be. After giving this more thought, I'm not sure there is much useful data (as far as I can tell) from the SSD that really necessitates having it on the list. However, I do like the idea you suggest, and I intend to do some more research on it.

Thank you for the reply.
 

zoomzoom

Guru
Joined
Sep 6, 2015
Messages
677
After giving this more thought, I'm not sure there is much useful data (as far as I can tell) from the SSD that really necessitates having it on the list.
I've never taken the time to go through the 200+ S.M.A.R.T value lines, however SSDs do use some of them, just not the same ones that are generally polled for HDDs.
 
Last edited:

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,996
I'm not sure how much time I will have to help, I need to fix the lights on my truck but could you please post or point me to the exact script you are using? This way I can see what you are looking at and offer proper help. Odds are that there are clues already in the script.

-Mark

EDIT: I think making the script fully automatic will be easy but it will take some research to make it correct. It may need to become something that evolves for each new SSD model and then you make a database of drive models. Eh, it's a job.
 

GBillR

Contributor
Joined
Jun 12, 2016
Messages
189
I'm not sure how much time I will have to help, I need to fix the lights on my truck but could you please post or point me to the exact script you are using? This way I can see what you are looking at and offer proper help. Odds are that there are clues already in the script.

-Mark

EDIT: I think making the script fully automatic will be easy but it will take some research to make it correct. It may need to become something that evolves for each new SSD model and then you make a database of drive models. Eh, it's a job.

Thank you Mark. I honestly think I'm happy with simply leaving the SSD off the emailed output for now. I truly appreciate your offer, and I will post the exact scripts and emailed outputs below for anyone who wants to look into this further. Ideally, the script would recognize an SSD and tailor the output as such. Given my SSD is not part of my data pool, I am slightly less concerned about it. However, it is a stand-alone boot pool, so if there truly is something in the SMART output that is worth monitoring then perhaps this should be included in the script output.

Below is the version of the script I am using. It's just the script from the first post in this thread, modified as described to auto-select all disks. I commented out the section to auto-select disks once I decided that the SSD ouput wasn't aligning correctly.
Code:
#!/bin/sh

### Parameters ###
logfile="/tmp/smart_report.tmp"
email="xxxxxx@hotmail.com"
subject="SMART Status Report for FreeNAS"
drives="ada1 ada2 ada3"

#drives=$(for drive in $(sysctl -n kern.disks); do \
#if [ "$(smartctl -i /dev/${drive} | grep "Serial Number" | awk '{print $3}')" ]
#then printf ${drive}" "; fi done | awk '{for (i=NF; i!=0 ; i--) print $i }')

tempWarn=35
tempCrit=40
sectorsCrit=0
testAgeWarn=7
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 ###
echo "<pre style=\"font-size:14px\">" >> "$logfile"

###### summary ######
(
	echo ""
	echo "########## SMART status report summary for all drives ##########"
	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 "########## SMART status report for ${drive} drive (${brand}: ${serial}) ##########"
		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>" >> "$logfile"

### Send report ###
sendmail -t < "$logfile"
rm "$logfile"


Here is the emailed output:

Code:
########## 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-WXG1A259PP95| 18 |  144|	4|	0|	  0|	  0|	   0|	 0|   N/A|   N/A|	N/A|   5|
|ada2  |WD-WCC4N4KY2PFX| 19 |  176|	9|	0|	  0|	  0|	   0|	 0|   N/A|   N/A|	N/A|   4|
|ada3  |WD-WCC4N2KNSYVF| 20 |  176|	9|	0|	  0|	  0|	   0|	 0|   N/A|   N/A|	N/A|   4|
+------+---------------+----+-----+-----+-----+-------+-------+--------+------+------+------+-------+----+



########## SMART status report for ada1 drive (Western Digital Black: WD-WXG1A259PP95) ##########
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   100   253   021	Pre-fail  Always	   -	   0
  4 Start_Stop_Count		0x0032   100   100   000	Old_age   Always	   -	   4
  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   100   100   000	Old_age   Always	   -	   144
 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	   -	   4
192 Power-Off_Retract_Count 0x0032   200   200   000	Old_age   Always	   -	   0
193 Load_Cycle_Count		0x0032   200   200   000	Old_age   Always	   -	   20
194 Temperature_Celsius	 0x0022   125   110   000	Old_age   Always	   -	   18
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   200   200   000	Old_age   Offline	  -	   0

No Errors Logged

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



########## SMART status report for ada2 drive (Western Digital Red: WD-WCC4N4KY2PFX) ##########
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	   -	   5866
  4 Start_Stop_Count		0x0032   100   100   000	Old_age   Always	   -	   9
  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   100   100   000	Old_age   Always	   -	   176
 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	   -	   9
192 Power-Off_Retract_Count 0x0032   200   200   000	Old_age   Always	   -	   0
193 Load_Cycle_Count		0x0032   200   200   000	Old_age   Always	   -	   49
194 Temperature_Celsius	 0x0022   131   119   000	Old_age   Always	   -	   19
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   200   200   000	Old_age   Offline	  -	   0

No Errors Logged

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



########## SMART status report for ada3 drive (Western Digital Red: WD-WCC4N2KNSYVF) ##########
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   176   176   021	Pre-fail  Always	   -	   6183
  4 Start_Stop_Count		0x0032   100   100   000	Old_age   Always	   -	   9
  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   100   100   000	Old_age   Always	   -	   176
 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	   -	   9
192 Power-Off_Retract_Count 0x0032   200   200   000	Old_age   Always	   -	   0
193 Load_Cycle_Count		0x0032   200   200   000	Old_age   Always	   -	   48
194 Temperature_Celsius	 0x0022   130   119   000	Old_age   Always	   -	   20
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   200   200   000	Old_age   Offline	  -	   0

No Errors Logged

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



And finally, when I swap the script back to permit auto-selection of the disks, here is the output:

Code:
########## 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 |
+------+---------------+----+-----+-----+-----+-------+-------+--------+------+------+------+-------+----+
|ada0 ?|163603456807   | 25 |220h+00m+00.000s|	 |	 |	   |	   |		|	  |   N/A|   N/A|	  0|   9|
|ada1  |WD-WXG1A259PP95| 18 |  144|	4|	0|	  0|	  0|	   0|	 0|   N/A|   N/A|	N/A|   5|
|ada2  |WD-WCC4N4KY2PFX| 19 |  177|	9|	0|	  0|	  0|	   0|	 0|   N/A|   N/A|	N/A|   4|
|ada3  |WD-WCC4N2KNSYVF| 20 |  177|	9|	0|	  0|	  0|	   0|	 0|   N/A|   N/A|	N/A|   4|
+------+---------------+----+-----+-----+-----+-------+-------+--------+------+------+------+-------+----+



########## SMART status report for ada0 drive (SandForce Driven SSDs: 163603456807) ##########
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
  5 Retired_Block_Count	 0x0032   100   100   000	Old_age   Always	   -	   0
  9 Power_On_Hours_and_Msec 0x0032   000   100   000	Old_age   Always	   -	   220h+00m+00.000s
 12 Power_Cycle_Count	   0x0032   100   100   000	Old_age   Always	   -	   10
165 Unknown_Attribute	   0x0032   100   100   000	Old_age   Always	   -	   65536
166 Unknown_Attribute	   0x0032   100   100   000	Old_age   Always	   -	   0
167 Unknown_Attribute	   0x0032   100   100   000	Old_age   Always	   -	   0
168 Unknown_Attribute	   0x0032   100   100   000	Old_age   Always	   -	   0
169 Unknown_Attribute	   0x0032   100   100   000	Old_age   Always	   -	   0
170 Reserve_Block_Count	 0x0032   100   100   000	Old_age   Always	   -	   0
171 Program_Fail_Count	  0x0032   100   100   000	Old_age   Always	   -	   0
172 Erase_Fail_Count		0x0032   100   100   000	Old_age   Always	   -	   0
173 Unknown_SandForce_Attr  0x0032   100   100   000	Old_age   Always	   -	   0
174 Unexpect_Power_Loss_Ct  0x0032   100   100   000	Old_age   Always	   -	   1
187 Reported_Uncorrect	  0x0032   100   100   000	Old_age   Always	   -	   0
188 Command_Timeout		 0x0032   100   100   000	Old_age   Always	   -	   0
194 Temperature_Celsius	 0x0022   075   057   000	Old_age   Always	   -	   25 (Min/Max 0/43)
199 SATA_CRC_Error_Count	0x0032   100   100   000	Old_age   Always	   -	   0
230 Life_Curve_Status	   0x0032   100   100   000	Old_age   Always	   -	   0
232 Available_Reservd_Space 0x0033   100   100   004	Pre-fail  Always	   -	   100
233 SandForce_Internal	  0x0032   100   100   000	Old_age   Always	   -	   0
234 SandForce_Internal	  0x0032   100   100   000	Old_age   Always	   -	   2
241 Lifetime_Writes_GiB	 0x0030   253   253   000	Old_age   Offline	  -	   1
242 Lifetime_Reads_GiB	  0x0030   253   253   000	Old_age   Offline	  -	   1
244 Unknown_Attribute	   0x0032   000   100   000	Old_age   Always	   -	   0

No Errors Logged

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



########## SMART status report for ada1 drive (Western Digital Black: WD-WXG1A259PP95) ##########
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   100   253   021	Pre-fail  Always	   -	   0
  4 Start_Stop_Count		0x0032   100   100   000	Old_age   Always	   -	   4
  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   100   100   000	Old_age   Always	   -	   144
 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	   -	   4
192 Power-Off_Retract_Count 0x0032   200   200   000	Old_age   Always	   -	   0
193 Load_Cycle_Count		0x0032   200   200   000	Old_age   Always	   -	   20
194 Temperature_Celsius	 0x0022   125   110   000	Old_age   Always	   -	   18
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   200   200   000	Old_age   Offline	  -	   0

No Errors Logged

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



########## SMART status report for ada2 drive (Western Digital Red: WD-WCC4N4KY2PFX) ##########
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	   -	   5866
  4 Start_Stop_Count		0x0032   100   100   000	Old_age   Always	   -	   9
  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   100   100   000	Old_age   Always	   -	   177
 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	   -	   9
192 Power-Off_Retract_Count 0x0032   200   200   000	Old_age   Always	   -	   0
193 Load_Cycle_Count		0x0032   200   200   000	Old_age   Always	   -	   49
194 Temperature_Celsius	 0x0022   131   119   000	Old_age   Always	   -	   19
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   200   200   000	Old_age   Offline	  -	   0

No Errors Logged

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



########## SMART status report for ada3 drive (Western Digital Red: WD-WCC4N2KNSYVF) ##########
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   176   176   021	Pre-fail  Always	   -	   6183
  4 Start_Stop_Count		0x0032   100   100   000	Old_age   Always	   -	   9
  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   100   100   000	Old_age   Always	   -	   177
 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	   -	   9
192 Power-Off_Retract_Count 0x0032   200   200   000	Old_age   Always	   -	   0
193 Load_Cycle_Count		0x0032   200   200   000	Old_age   Always	   -	   48
194 Temperature_Celsius	 0x0022   130   119   000	Old_age   Always	   -	   20
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   200   200   000	Old_age   Offline	  -	   0

No Errors Logged

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



When I run smartctl -x /dev/ada0, I honestly do not see a lot of data that I could/would substitute into this script, but I may be underestimating the value of some of the below data:

Code:
[root@freenas] /mnt/Tank/scripts# smartctl -x /dev/ada0
smartctl 6.5 2016-05-07 r4318 [FreeBSD 10.3-STABLE amd64] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:	 SandForce Driven SSDs
Device Model:	 SanDisk SDSSDA120G
Serial Number:	163603456807
LU WWN Device Id: 5 001b44 4a430d9dc
Firmware Version: Z32080RL
User Capacity:	120,034,123,776 bytes [120 GB]
Sector Size:	  512 bytes logical/physical
Rotation Rate:	Solid State Device
Form Factor:	  2.5 inches
Device is:		In smartctl database [for details use: -P show]
ATA Version is:   ACS-2 T13/2015-D revision 3
SATA Version is:  SATA 3.2, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:	Fri Jan  6 09:42:03 2017 EST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
AAM feature is:   Unavailable
APM level is:	 128 (minimum power consumption without standby)
Rd look-ahead is: Enabled
Write cache is:   Enabled
ATA Security is:  Disabled, NOT FROZEN [SEC1]
Wt Cache Reorder: Unavailable

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status:  (0x00) Offline data collection activity
										was never started.
										Auto Offline Data Collection: Disabled.
Self-test execution status:	  (   0) The previous self-test routine completed
										without error or no self-test has ever
										been run.
Total time to complete Offline
data collection:				(  120) seconds.
Offline data collection
capabilities:					(0x11) SMART execute Offline immediate.
										No Auto Offline data collection support.
										Suspend Offline collection upon new
										command.
										No Offline surface scan supported.
										Self-test supported.
										No Conveyance Self-test supported.
										No Selective Self-test supported.
SMART capabilities:			(0x0003) Saves SMART data before entering
										power-saving mode.
										Supports SMART auto save timer.
Error logging capability:		(0x01) Error logging supported.
										General Purpose Logging supported.
Short self-test routine
recommended polling time:		(   2) minutes.
Extended self-test routine
recommended polling time:		(  10) minutes.

SMART Attributes Data Structure revision number: 1
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME		  FLAGS	VALUE WORST THRESH FAIL RAW_VALUE
  5 Retired_Block_Count	 -O--CK   100   100   000	-	0
  9 Power_On_Hours_and_Msec -O--CK   000   100   000	-	221h+00m+00.000s
 12 Power_Cycle_Count	   -O--CK   100   100   000	-	10
165 Unknown_Attribute	   -O--CK   100   100   000	-	65536
166 Unknown_Attribute	   -O--CK   100   100   000	-	0
167 Unknown_Attribute	   -O--CK   100   100   000	-	0
168 Unknown_Attribute	   -O--CK   100   100   000	-	0
169 Unknown_Attribute	   -O--CK   100   100   000	-	0
170 Reserve_Block_Count	 -O--CK   100   100   000	-	0
171 Program_Fail_Count	  -O--CK   100   100   000	-	0
172 Erase_Fail_Count		-O--CK   100   100   000	-	0
173 Unknown_SandForce_Attr  -O--CK   100   100   000	-	0
174 Unexpect_Power_Loss_Ct  -O--CK   100   100   000	-	1
187 Reported_Uncorrect	  -O--CK   100   100   000	-	0
188 Command_Timeout		 -O--CK   100   100   000	-	0
194 Temperature_Celsius	 -O---K   075   057   000	-	25 (Min/Max 0/43)
199 SATA_CRC_Error_Count	-O--CK   100   100   000	-	0
230 Life_Curve_Status	   -O--CK   100   100   000	-	0
232 Available_Reservd_Space PO--CK   100   100   004	-	100
233 SandForce_Internal	  -O--CK   100   100   000	-	0
234 SandForce_Internal	  -O--CK   100   100   000	-	2
241 Lifetime_Writes_GiB	 ----CK   253   253   000	-	1
242 Lifetime_Reads_GiB	  ----CK   253   253   000	-	1
244 Unknown_Attribute	   -O--CK   000   100   000	-	0
							||||||_ K auto-keep
							|||||__ C event count
							||||___ R error rate
							|||____ S speed/performance
							||_____ O updated online
							|______ P prefailure warning

General Purpose Log Directory Version 1
SMART		   Log Directory Version 1 [multi-sector log support]
Address	Access  R/W   Size  Description
0x00	   GPL,SL  R/O	  1  Log Directory
0x01		   SL  R/O	  1  Summary SMART error log
0x02		   SL  R/O	  1  Comprehensive SMART error log
0x03	   GPL	 R/O	  1  Ext. Comprehensive SMART error log
0x04	   GPL,SL  R/O	  8  Device Statistics log
0x06		   SL  R/O	  1  SMART self-test log
0x07	   GPL	 R/O	  1  Extended self-test log
0x10	   GPL	 R/O	  1  SATA NCQ Queued Error log
0x11	   GPL	 R/O	  1  SATA Phy Event Counters log
0x30	   GPL,SL  R/O	  9  IDENTIFY DEVICE data log
0x80-0x9f  GPL,SL  R/W	 16  Host vendor specific log
0xde	   GPL	 VS	   8  Device vendor specific log

SMART Extended Comprehensive Error Log Version: 1 (1 sectors)
No Errors Logged

SMART Extended Self-test Log Version: 1 (1 sectors)
Num  Test_Description	Status				  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Short offline	   Completed without error	   00%		 8		 -

Selective Self-tests/Logging not supported

SCT Commands not supported

Device Statistics (GP Log 0x04)
Page  Offset Size		Value Flags Description
0x01  =====  =			   =  ===  == General Statistics (rev 1) ==
0x01  0x008  4			  10  ---  Lifetime Power-On Resets
0x01  0x010  4			 221  ---  Power-on Hours
0x01  0x018  6		 4154904  ---  Logical Sectors Written
0x01  0x020  6		  143969  ---  Number of Write Commands
0x01  0x028  6		 3392043  ---  Logical Sectors Read
0x01  0x030  6		  166986  ---  Number of Read Commands
0x07  =====  =			   =  ===  == Solid State Device Statistics (rev 1) ==
0x07  0x008  1			   0  ---  Percentage Used Endurance Indicator
								|||_ C monitored condition met
								||__ D supports DSN
								|___ N normalized value

SATA Phy Event Counters (GP Log 0x11)
ID	  Size	 Value  Description
0x0001  4			0  Command failed due to ICRC error
0x0002  4			0  R_ERR response for data FIS
0x0005  4			2  R_ERR response for non-data FIS
0x000a  4			5  Device-to-host register FISes sent due to a COMRESET


I hope all of the formatting I've done sticks when I hit reply here... It looks correct on my screen.

-Bill
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,996
So here is a very quick fix, also I noted there was an error in the code, just an update really.

So at the top of the script, add the second line listed here:
Code:
drives="ada1 ada2 ada3"
drives_smart_data="ada0 ada1 ada2 ada3"

Now scroll down to line 90 where is says:
Code:
###### for each drive ######
for drive in $drives

And Change it to read:
Code:
for drive in $drives_smart_data


And for the code update, scroll down to new line 103, change the "smartctl 6.3/d" to "smartctl 6.5/d" and this will remove the line identified from the reports that is making it through right now. It's minor but it's there. Actually I'd just change it to "smartctl/d" in order to future proof it but I leave that up to you.

So what did I do?
I now made the script run slightly different, the first parameter for $drives works to only collect the summary data and you wanted to drop ada0 from the list. I thought about changing all the values from "drives" to "drives_summary" for clarity but then I need to add some complexity to the change for anyone who wants to modify it. And the main change was adding the new value "drives_smart_data" and this will identify which drives the smartctl data should be generated for. So instead of using a single parameter to identify this, two are now in use.

Something else I'd like to change is for the output of the smartctl data, it only lists the most recent smart test. I'd like it to list the most recent Short and Extended tests. In my situation I do a short test 7 days of the week and on Sunday I do a Long (Extended) test. I'd like to ensure that i'm actually performing a long test. And why do I care you say? Well while working on this script I discovered that my drives have not performed a long test in a while. Looks like when doing an upgrade my SMART tests were no longer working properly. And you know, I read about this issue but never checked my own system. I think I may run this script myself with some tweaks. I prefer to get warning emails with the word WARNING in the subject line, otherwise it's just a routine status message.

Hopefully this minor change helps.
 

zoomzoom

Guru
Joined
Sep 6, 2015
Messages
677
Something else I'd like to change is for the output of the smartctl data, it only lists the most recent smart test. I'd like it to list the most recent Short and Extended tests.
I could very well be wrong, but I believe one would have to identify if any of the 200+ S.M.A.R.T value lines list results of short & long tests separately.
  • If they don't, the easiest way to include that information in the emailed output may be to set up a cron job to run a script after each short & long test, saving the date of the test, then have the smart_report script poll that text file for the date in order to get the data to include in a separate column in the output.
    • I'd imagine there's a command that would allow the computation of the x amount of days since the last test was ran, however I'm not sure what that command would be =]
I'd like to ensure that i'm actually performing a long test. ...I prefer to get warning emails with the word WARNING in the subject line, otherwise it's just a routine status message.
The individual drive output, below the synopsis of all drives, lists all short and long tests performed on each drive and when they were performed [drive hours of operation]. Subject line can be modified in the subject variable (although I could be misconstruing, as you may mean in regards to a smart test not being ran in x amount of days)
  • For example, mine is: subject="S.M.A.R.T Status Report for Fractals.NAS"
 
Last edited:

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,996
I've already adjusted the script to push out the last Short and Long tests. Now it's just a simple subject line change but you need to check for a Warning/Error and then change the subject line automatically. I'll post the updated script when I'm done with it. I like to test things out well before I post them. Also, I need to take a lunch break and OMG, the snow is coming down! Hope it stops soon so I can get out there and shovel the white fluffy stuff.
 

zoomzoom

Guru
Joined
Sep 6, 2015
Messages
677
When I run smartctl -x /dev/ada0, I honestly do not see a lot of data that I could/would substitute into this script, but I may be underestimating the value of some of the below data:
Code:
SMART Attributes Data Structure revision number: 1
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME		  FLAGS	VALUE WORST THRESH FAIL RAW_VALUE
  5 Retired_Block_Count	 -O--CK   100   100   000	-	0
  9 Power_On_Hours_and_Msec -O--CK   000   100   000	-	221h+00m+00.000s
12 Power_Cycle_Count	   -O--CK   100   100   000	-	10
165 Unknown_Attribute	   -O--CK   100   100   000	-	65536
166 Unknown_Attribute	   -O--CK   100   100   000	-	0
167 Unknown_Attribute	   -O--CK   100   100   000	-	0
168 Unknown_Attribute	   -O--CK   100   100   000	-	0
169 Unknown_Attribute	   -O--CK   100   100   000	-	0
170 Reserve_Block_Count	 -O--CK   100   100   000	-	0
171 Program_Fail_Count	  -O--CK   100   100   000	-	0
172 Erase_Fail_Count		-O--CK   100   100   000	-	0
173 Unknown_SandForce_Attr  -O--CK   100   100   000	-	0
174 Unexpect_Power_Loss_Ct  -O--CK   100   100   000	-	1
187 Reported_Uncorrect	  -O--CK   100   100   000	-	0
188 Command_Timeout		 -O--CK   100   100   000	-	0
194 Temperature_Celsius	 -O---K   075   057   000	-	25 (Min/Max 0/43)
199 SATA_CRC_Error_Count	-O--CK   100   100   000	-	0
230 Life_Curve_Status	   -O--CK   100   100   000	-	0
232 Available_Reservd_Space PO--CK   100   100   004	-	100
233 SandForce_Internal	  -O--CK   100   100   000	-	0
234 SandForce_Internal	  -O--CK   100   100   000	-	2
241 Lifetime_Writes_GiB	 ----CK   253   253   000	-	1
242 Lifetime_Reads_GiB	  ----CK   253   253   000	-	1
244 Unknown_Attribute	   -O--CK   000   100   000	-	0
							||||||_ K auto-keep
							|||||__ C event count
							||||___ R error rate
							|||____ S speed/performance
							||_____ O updated online
							|______ P prefailure warning

General Purpose Log Directory Version 1
SMART		   Log Directory Version 1 [multi-sector log support]
Address	Access  R/W   Size  Description
0x00	   GPL,SL  R/O	  1  Log Directory
0x01		   SL  R/O	  1  Summary SMART error log
0x02		   SL  R/O	  1  Comprehensive SMART error log
0x03	   GPL	 R/O	  1  Ext. Comprehensive SMART error log
0x04	   GPL,SL  R/O	  8  Device Statistics log
0x06		   SL  R/O	  1  SMART self-test log
0x07	   GPL	 R/O	  1  Extended self-test log
0x10	   GPL	 R/O	  1  SATA NCQ Queued Error log
0x11	   GPL	 R/O	  1  SATA Phy Event Counters log
0x30	   GPL,SL  R/O	  9  IDENTIFY DEVICE data log
0x80-0x9f  GPL,SL  R/W	 16  Host vendor specific log
0xde	   GPL	 VS	   8  Device vendor specific log

SMART Extended Comprehensive Error Log Version: 1 (1 sectors)
No Errors Logged

SMART Extended Self-test Log Version: 1 (1 sectors)
Num  Test_Description	Status				  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Short offline	   Completed without error	   00%		 8		 -

Selective Self-tests/Logging not supported

SCT Commands not supported

Device Statistics (GP Log 0x04)
Page  Offset Size		Value Flags Description
0x01  =====  =			   =  ===  == General Statistics (rev 1) ==
0x01  0x008  4			  10  ---  Lifetime Power-On Resets
0x01  0x010  4			 221  ---  Power-on Hours
0x01  0x018  6		 4154904  ---  Logical Sectors Written
0x01  0x020  6		  143969  ---  Number of Write Commands
0x01  0x028  6		 3392043  ---  Logical Sectors Read
0x01  0x030  6		  166986  ---  Number of Read Commands
0x07  =====  =			   =  ===  == Solid State Device Statistics (rev 1) ==
0x07  0x008  1			   0  ---  Percentage Used Endurance Indicator
								|||_ C monitored condition met
								||__ D supports DSN
								|___ N normalized value

SATA Phy Event Counters (GP Log 0x11)
ID	  Size	 Value  Description
0x0001  4			0  Command failed due to ICRC error
0x0002  4			0  R_ERR response for data FIS
0x0005  4			2  R_ERR response for non-data FIS
0x000a  4			5  Device-to-host register FISes sent due to a COMRESET
There is some information in there you're going to want to be informed of regularly.
 
Last edited:

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,996
So here is the modified script. Note that it does not change the Subject Line (Yet) but it will display the most recent Short and Extended tests. I also left it modified for @GBillR but he left it so it could be restored like normal scanning of the hard drives.

Code:
#!/bin/sh
 
### Parameters ###
logfile="/tmp/smart_report.tmp"
email="youremailaddress@hotmail.com"
subject="SMART Status Report for FreeNAS"
drives="ada1 ada2 ada3"
drives_smart_data="ada0 ada1 ada2 ada3"
 
#drives=$(for drive in $(sysctl -n kern.disks); do \
#if [ "$(smartctl -i /dev/${drive} | grep "Serial Number" | awk '{print $3}')" ]
#then printf ${drive}" "; fi done | awk '{for (i=NF; i!=0 ; i--) print $i }')
 
tempWarn=35
tempCrit=40
sectorsCrit=0
testAgeWarn=7
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 ###
echo "<pre style=\"font-size:14px\">" >> "$logfile"
 
###### summary ######
(
	echo ""
	echo "########## SMART status report summary for all drives ##########"
	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_smart_data
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 "########## SMART status report for ${drive} drive (${brand}: ${serial}) ##########"
		smartctl -H -A -l error /dev/"$drive"
		smartctl -l selftest /dev/"$drive" | grep "Extended \|Num" | cut -c6- | head -2
		smartctl -l selftest /dev/"$drive" | grep "Short \|Num" | cut -c6- | head -2 | tail -n -1
		echo ""
		echo ""
	) >> "$logfile"
done
sed -i '' -e '/smartctl/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>" >> "$logfile"
 
### Send report ###
sendmail -t < "$logfile"
#rm "$logfile"


And here is a sample output (note that I do have a few warnings):
Code:
 
########## 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-WMC301183577| 31 |32401|  250|	0|	  0|	  0|	   0|	 0|   N/A|   N/A|	N/A|   0|
|ada2  |WD-WMC300411588| 31 |36304|  473|	0|	  0|	  0|	   0|	 0|   N/A|   N/A|	N/A|   0|
|ada3  |WD-WMC300411516| 31 |36308|  481|	0|	  0|	  0|	   0|	 0|   N/A|   N/A|	N/A|   0|
|ada4 ?|WD-WMC300412480| 32 |36288|  469|	0|	  0|	  0|	   0|	 0|   N/A|   N/A|	N/A|  76|
|ada5 ?|WD-WMC300410673| 33 |36312|  484|	0|	  0|	  0|	   0|	 0|   N/A|   N/A|	N/A|  76|
+------+---------------+----+-----+-----+-----+-------+-------+--------+------+------+------+-------+----+
 
 
 
########## SMART status report for ada0 drive (Western Digital Red: WD-WMC301176182) ##########
 
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	   -	   1
  3 Spin_Up_Time			0x0027   180   172   021	Pre-fail  Always	   -	   3983
  4 Start_Stop_Count		0x0032   100   100   000	Old_age   Always	   -	   267
  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   055   055   000	Old_age   Always	   -	   32855
10 Spin_Retry_Count		0x0032   100   100   000	Old_age   Always	   -	   0
11 Calibration_Retry_Count 0x0032   100   100   000	Old_age   Always	   -	   0
12 Power_Cycle_Count	   0x0032   100   100   000	Old_age   Always	   -	   185
192 Power-Off_Retract_Count 0x0032   200   200   000	Old_age   Always	   -	   97
193 Load_Cycle_Count		0x0032   200   200   000	Old_age   Always	   -	   169
194 Temperature_Celsius	 0x0022   116   106   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   200   200   000	Old_age   Offline	  -	   0
 
No Errors Logged
 
Test_Description	Status				  Remaining  LifeTime(hours)  LBA_of_first_error
Extended offline	Completed without error	   00%	 30891		 -
Short offline	   Completed without error	   00%	 32852		 -
 
 
 
########## SMART status report for ada1 drive (Western Digital Red: WD-WMC301183577) ##########
 
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   175   171   021	Pre-fail  Always	   -	   4216
  4 Start_Stop_Count		0x0032   100   100   000	Old_age   Always	   -	   250
  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   056   056   000	Old_age   Always	   -	   32401
10 Spin_Retry_Count		0x0032   100   100   000	Old_age   Always	   -	   0
11 Calibration_Retry_Count 0x0032   100   100   000	Old_age   Always	   -	   0
12 Power_Cycle_Count	   0x0032   100   100   000	Old_age   Always	   -	   172
192 Power-Off_Retract_Count 0x0032   200   200   000	Old_age   Always	   -	   93
193 Load_Cycle_Count		0x0032   200   200   000	Old_age   Always	   -	   156
194 Temperature_Celsius	 0x0022   116   106   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   200   200   000	Old_age   Offline	  -	   0
 
No Errors Logged
 
Test_Description	Status				  Remaining  LifeTime(hours)  LBA_of_first_error
Extended offline	Completed without error	   00%	 30437		 -
Short offline	   Completed without error	   00%	 32398		 -
 
 
 
########## SMART status report for ada2 drive (Western Digital Red: WD-WMC300411588) ##########
 
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   181   173   021	Pre-fail  Always	   -	   3916
  4 Start_Stop_Count		0x0032   100   100   000	Old_age   Always	   -	   473
  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   051   051   000	Old_age   Always	   -	   36304
10 Spin_Retry_Count		0x0032   100   100   000	Old_age   Always	   -	   0
11 Calibration_Retry_Count 0x0032   100   100   000	Old_age   Always	   -	   0
12 Power_Cycle_Count	   0x0032   100   100   000	Old_age   Always	   -	   230
192 Power-Off_Retract_Count 0x0032   200   200   000	Old_age   Always	   -	   116
193 Load_Cycle_Count		0x0032   200   200   000	Old_age   Always	   -	   356
194 Temperature_Celsius	 0x0022   116   105   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   200   200   000	Old_age   Offline	  -	   0
 
No Errors Logged
 
Test_Description	Status				  Remaining  LifeTime(hours)  LBA_of_first_error
Extended offline	Completed without error	   00%	 34340		 -
Short offline	   Completed without error	   00%	 36301		 -
 
 
 
########## SMART status report for ada3 drive (Western Digital Red: WD-WMC300411516) ##########
 
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	   -	   31
  3 Spin_Up_Time			0x0027   181   174   021	Pre-fail  Always	   -	   3941
  4 Start_Stop_Count		0x0032   100   100   000	Old_age   Always	   -	   481
  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   051   051   000	Old_age   Always	   -	   36308
10 Spin_Retry_Count		0x0032   100   100   000	Old_age   Always	   -	   0
11 Calibration_Retry_Count 0x0032   100   100   000	Old_age   Always	   -	   0
12 Power_Cycle_Count	   0x0032   100   100   000	Old_age   Always	   -	   231
192 Power-Off_Retract_Count 0x0032   200   200   000	Old_age   Always	   -	   116
193 Load_Cycle_Count		0x0032   200   200   000	Old_age   Always	   -	   364
194 Temperature_Celsius	 0x0022   116   107   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   200   200   000	Old_age   Offline	  -	   0
 
No Errors Logged
 
Test_Description	Status				  Remaining  LifeTime(hours)  LBA_of_first_error
Extended offline	Completed without error	   00%	 34344		 -
Short offline	   Completed without error	   00%	 36305		 -
 
 
 
########## SMART status report for ada4 drive (Western Digital Red: WD-WMC300412480) ##########
 
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   175   172   021	Pre-fail  Always	   -	   4225
  4 Start_Stop_Count		0x0032   100   100   000	Old_age   Always	   -	   469
  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   051   051   000	Old_age   Always	   -	   36288
10 Spin_Retry_Count		0x0032   100   100   000	Old_age   Always	   -	   0
11 Calibration_Retry_Count 0x0032   100   100   000	Old_age   Always	   -	   0
12 Power_Cycle_Count	   0x0032   100   100   000	Old_age   Always	   -	   229
192 Power-Off_Retract_Count 0x0032   200   200   000	Old_age   Always	   -	   116
193 Load_Cycle_Count		0x0032   200   200   000	Old_age   Always	   -	   562
194 Temperature_Celsius	 0x0022   115   103   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   200   200   000	Old_age   Offline	  -	   0
 
No Errors Logged
 
Test_Description	Status				  Remaining  LifeTime(hours)  LBA_of_first_error
Extended offline	Completed without error	   00%	 34325		 -
Short offline	   Completed without error	   00%	 34463		 -
 
 
 
########## SMART status report for ada5 drive (Western Digital Red: WD-WMC300410673) ##########
 
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   180   172   021	Pre-fail  Always	   -	   4000
  4 Start_Stop_Count		0x0032   100   100   000	Old_age   Always	   -	   484
  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   051   051   000	Old_age   Always	   -	   36312
10 Spin_Retry_Count		0x0032   100   100   000	Old_age   Always	   -	   0
11 Calibration_Retry_Count 0x0032   100   100   000	Old_age   Always	   -	   0
12 Power_Cycle_Count	   0x0032   100   100   000	Old_age   Always	   -	   233
192 Power-Off_Retract_Count 0x0032   200   200   000	Old_age   Always	   -	   117
193 Load_Cycle_Count		0x0032   200   200   000	Old_age   Always	   -	   366
194 Temperature_Celsius	 0x0022   114   103   000	Old_age   Always	   -	   33
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   200   200   000	Old_age   Offline	  -	   0
 
No Errors Logged
 
Test_Description	Status				  Remaining  LifeTime(hours)  LBA_of_first_error
Extended offline	Completed without error	   00%	 34349		 -
Short offline	   Completed without error	   00%	 34487		 -
 
Last edited:

GBillR

Contributor
Joined
Jun 12, 2016
Messages
189
So here is the modified script. Note that it does not change the Subject Line (Yet) but it will display the most recent Short and Extended tests. I also left it modified for @GBillR but he left it so it could be restored like normal scanning of the hard drives.

Thank you for taking the time to do this, and to explain the changes you've made. I'm a total noob at script writing, but I have been working to improve my understanding.

Also, I agree @zoomzoom that there is definitely SSD related data there that would be of value to monitor on a regular basis.
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
@Bidule0hm - Thank you for your work on these... simply awesome effort.

I am having a minor formatting issue with the smart script. my SSD reports POH in xxxh+00m+00.00s. As a result, the emailed table formatting is a bit off:
Code:
########## 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 |
+------+---------------+----+-----+-----+-----+-------+-------+--------+------+------+------+-------+----+
|ada0 ?|163603456807  | 25 |161h+00m+00.000s|  |  |  |  |  |  |  N/A|  N/A|  0|  6|
|ada1 ?|WD-WXG1A259PP95| 18 |  83|  4|  0|  0|  0|  0|  0|  N/A|  N/A|  N/A|  3|
|ada2  |WD-WCC4N4KY2PFX| 19 |  115|  9|  0|  0|  0|  0|  0|  N/A|  N/A|  N/A|  1|
|ada3  |WD-WCC4N2KNSYVF| 20 |  115|  9|  0|  0|  0|  0|  0|  N/A|  N/A|  N/A|  1|
+------+---------------+----+-----+-----+-----+-------+-------+--------+------+------+------+-------+----+



########## SMART status report for ada0 drive (SandForce Driven SSDs: 163603456807) ##########
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
  5 Retired_Block_Count  0x0032  100  100  000  Old_age  Always  -  0
  9 Power_On_Hours_and_Msec 0x0032  000  100  000  Old_age  Always  -  161h+00m+00.000s
12 Power_Cycle_Count  0x0032  100  100  000  Old_age  Always  -  10
165 Unknown_Attribute  0x0032  100  100  000  Old_age  Always   -  65536
166 Unknown_Attribute  0x0032  100  100  000  Old_age  Always  -  0
167 Unknown_Attribute  0x0032  100  100  000  Old_age  Always  -  0
168 Unknown_Attribute  0x0032  100  100  000  Old_age  Always  -  0
169 Unknown_Attribute  0x0032  100  100  000  Old_age  Always  -  0
170 Reserve_Block_Count  0x0032  100  100  000  Old_age  Always  -  0
171 Program_Fail_Count  0x0032  100  100   000  Old_age  Always  -  0
172 Erase_Fail_Count  0x0032  100  100  000  Old_age  Always  -  0
173 Unknown_SandForce_Attr  0x0032  100  100  000  Old_age  Always  -  0
174 Unexpect_Power_Loss_Ct  0x0032  100  100  000  Old_age  Always  -  1
187 Reported_Uncorrect  0x0032  100  100  000  Old_age  Always  -  0
188 Command_Timeout  0x0032  100  100  000  Old_age  Always  -  0
194 Temperature_Celsius   0x0022  075  057  000  Old_age  Always  -  25 (Min/Max 0/43)
199 SATA_CRC_Error_Count  0x0032  100  100  000  Old_age  Always  -  0
230 Life_Curve_Status  0x0032  100  100  000  Old_age  Always  -  0
232 Available_Reservd_Space 0x0033  100  100  004  Pre-fail  Always  -  100
233 SandForce_Internal  0x0032  100  100  000  Old_age  Always  -  0
234 SandForce_Internal  0x0032  100  100  000  Old_age  Always   -  2
241 Lifetime_Writes_GiB  0x0030  253  253  000  Old_age  Offline  -  1
242 Lifetime_Reads_GiB  0x0030  253  253  000  Old_age  Offline  -  1
244 Unknown_Attribute  0x0032  000  100  000  Old_age  Always  -  0

No Errors Logged

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


I'm no Bash expert (barely know enough to be dangerous)... Any suggestions on how best to modify the following line to achieve the desired POH output for my SSD:

/Power_On_Hours/{onHours=$10} \

Thank you in advance.
This code returns just the hour portion of strings of the form "Xh+XXm+XX.XXXs"... but I haven't figured out how to make it work in the script, yet.
Code:
onHours=$(echo ${onHours} | rev | sed 's/.*+//' | rev | sed 's/\h//g')
EDIT: My awk skills are a little rusty, but I've figured out a patch. Replace this line of code:
Code:
/Power_On_Hours/{onHours=$10} \
with this code:
Code:
 /Power_On_Hours/{split($10,a,"+");sub(/h/,"",a[1]);onHours=a[1];} \
This leaves the standard integer 'Power_On_Hours' unchanged, so it won't adversely affect anyone else's scripts. It will split your SSD's 'Power_on_Hours_and_MSec' string into substrings as delimited by the '+' character, discarding all but the first substring, which gives us the hours with an 'h' suffix. It strips off this extraneous 'h', and - voila! - we have the simple integer value we desire!
 
Last edited:

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,996
This code returns just the hour portion of strings of the form "Xh+XXm+XX.XXXs"... but I haven't figured out how to make it work in the script, yet.
Code:
onHours=$(echo ${onHours} | rev | sed 's/.*+//' | rev | sed 's/\h//g')
Scripts are just so much fun!

Awk is such a pain and I'm still learning it myself. I see what you are doing with your code and if you could place it directly after onHours is defined then I know it could work fine.

Also, I agree @zoomzoom that there is definitely SSD related data there that would be of value to monitor on a regular basis.
Eh, I'm not sure what data should be passed except maybe the Health "PASSED" indication from this SSD. I suspect that the value for ID 232 might be the weal level count but I'm just guessing, but it that is true then that would be good to know as well. Regardless you should have a completely custom script to embed this data.
 

zoomzoom

Guru
Joined
Sep 6, 2015
Messages
677
Eh, I'm not sure what data should be passed except maybe the Health "PASSED" indication from this SSD. I suspect that the value for ID 232 might be the weal level count but I'm just guessing, but it that is true then that would be good to know as well. Regardless you should have a completely custom script to embed this data.
232 is the amount of reserved space an ssd has to work with to move data around for wear leveling. Generally, the reserve space is ~10% of the drive's formatted capacity, and if the reserve space is diminished, performance will be significantly degraded. While a 10% reserve is a general rule of thumb for all drives, with SSDs it's critical.
 

GBillR

Contributor
Joined
Jun 12, 2016
Messages
189
EDIT: My awk skills are a little rusty, but I've figured out a patch. Replace this line of code:
Code:
/Power_On_Hours/{onHours=$10} \
with this code:
Code:
 /Power_On_Hours/{split($10,a,"+");sub(/h/,"",a[1]);onHours=a[1];} \
This leaves the standard integer 'Power_On_Hours' unchanged, so it won't adversely affect anyone else's scripts. It will split your SSD's 'Power_on_Hours_and_MSec' string into substrings as delimited by the '+' character, discarding all but the first substring, which gives us the hours with an 'h' suffix. It strips off this extraneous 'h', and - voila! - we have the simple integer value we desire!
Thank you for working this out. I definitely have some homework to do on working with scripts.

As for mining useful data from the smart output for the SSD--wouldn't the info below be worth tracking? Would the "percentage used endurance" information be found anywhere else but in this statistics section?

Code:
Device Statistics (GP Log 0x04)
Page  Offset Size		Value Flags Description
0x01  =====  =			   =  ===  == General Statistics (rev 1) ==
0x01  0x008  4			  10  ---  Lifetime Power-On Resets
0x01  0x010  4			 221  ---  Power-on Hours
0x01  0x018  6		 4154904  ---  Logical Sectors Written
0x01  0x020  6		  143969  ---  Number of Write Commands
0x01  0x028  6		 3392043  ---  Logical Sectors Read
0x01  0x030  6		  166986  ---  Number of Read Commands
0x07  =====  =			   =  ===  == Solid State Device Statistics (rev 1) ==
0x07  0x008  1			   0  ---  Percentage Used Endurance Indicator
								|||_ C monitored condition met
								||__ D supports DSN
								|___ N normalized value
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Sorry for not being here for a long time, but I see everyone seems to have found an answer to their questions :) A big thanks to @joeschmuck who helped a lot ;)

And for the code update, scroll down to new line 103, change the "smartctl 6.3/d" to "smartctl 6.5/d" and this will remove the line identified from the reports that is making it through right now. It's minor but it's there. Actually I'd just change it to "smartctl/d" in order to future proof it but I leave that up to you.

Thanks for noticing that, I'll correct it ASAP and add the short/long last tests while I'm at it ;)
 

StorageEater

Dabbler
Joined
Sep 17, 2016
Messages
10
So here is the modified script. Note that it does not change the Subject Line (Yet) but it will display the most recent Short and Extended tests. I also left it modified for @GBillR but he left it so it could be restored like normal scanning of the hard drives.

Code:
#!/bin/sh

### Parameters ###
logfile="/tmp/smart_report.tmp"
email="youremailaddress@hotmail.com"
subject="SMART Status Report for FreeNAS"
drives="ada1 ada2 ada3"
drives_smart_data="ada0 ada1 ada2 ada3"

#drives=$(for drive in $(sysctl -n kern.disks); do \
#if [ "$(smartctl -i /dev/${drive} | grep "Serial Number" | awk '{print $3}')" ]
#then printf ${drive}" "; fi done | awk '{for (i=NF; i!=0 ; i--) print $i }')

tempWarn=35
tempCrit=40
sectorsCrit=0
testAgeWarn=7
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 ###
echo "<pre style=\"font-size:14px\">" >> "$logfile"

###### summary ######
(
	echo ""
	echo "########## SMART status report summary for all drives ##########"
	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_smart_data
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 "########## SMART status report for ${drive} drive (${brand}: ${serial}) ##########"
		smartctl -H -A -l error /dev/"$drive"
		smartctl -l selftest /dev/"$drive" | grep "Extended \|Num" | cut -c6- | head -2
		smartctl -l selftest /dev/"$drive" | grep "Short \|Num" | cut -c6- | head -2 | tail -n -1
		echo ""
		echo ""
	) >> "$logfile"
done
sed -i '' -e '/smartctl/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>" >> "$logfile"

### Send report ###
sendmail -t < "$logfile"
#rm "$logfile"


And here is a sample output (note that I do have a few warnings):
Code:

########## 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-WMC301183577| 31 |32401|  250|	0|	  0|	  0|	   0|	 0|   N/A|   N/A|	N/A|   0|
|ada2  |WD-WMC300411588| 31 |36304|  473|	0|	  0|	  0|	   0|	 0|   N/A|   N/A|	N/A|   0|
|ada3  |WD-WMC300411516| 31 |36308|  481|	0|	  0|	  0|	   0|	 0|   N/A|   N/A|	N/A|   0|
|ada4 ?|WD-WMC300412480| 32 |36288|  469|	0|	  0|	  0|	   0|	 0|   N/A|   N/A|	N/A|  76|
|ada5 ?|WD-WMC300410673| 33 |36312|  484|	0|	  0|	  0|	   0|	 0|   N/A|   N/A|	N/A|  76|
+------+---------------+----+-----+-----+-----+-------+-------+--------+------+------+------+-------+----+



########## SMART status report for ada0 drive (Western Digital Red: WD-WMC301176182) ##########

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	   -	   1
  3 Spin_Up_Time			0x0027   180   172   021	Pre-fail  Always	   -	   3983
  4 Start_Stop_Count		0x0032   100   100   000	Old_age   Always	   -	   267
  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   055   055   000	Old_age   Always	   -	   32855
10 Spin_Retry_Count		0x0032   100   100   000	Old_age   Always	   -	   0
11 Calibration_Retry_Count 0x0032   100   100   000	Old_age   Always	   -	   0
12 Power_Cycle_Count	   0x0032   100   100   000	Old_age   Always	   -	   185
192 Power-Off_Retract_Count 0x0032   200   200   000	Old_age   Always	   -	   97
193 Load_Cycle_Count		0x0032   200   200   000	Old_age   Always	   -	   169
194 Temperature_Celsius	 0x0022   116   106   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   200   200   000	Old_age   Offline	  -	   0

No Errors Logged

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



########## SMART status report for ada1 drive (Western Digital Red: WD-WMC301183577) ##########

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   175   171   021	Pre-fail  Always	   -	   4216
  4 Start_Stop_Count		0x0032   100   100   000	Old_age   Always	   -	   250
  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   056   056   000	Old_age   Always	   -	   32401
10 Spin_Retry_Count		0x0032   100   100   000	Old_age   Always	   -	   0
11 Calibration_Retry_Count 0x0032   100   100   000	Old_age   Always	   -	   0
12 Power_Cycle_Count	   0x0032   100   100   000	Old_age   Always	   -	   172
192 Power-Off_Retract_Count 0x0032   200   200   000	Old_age   Always	   -	   93
193 Load_Cycle_Count		0x0032   200   200   000	Old_age   Always	   -	   156
194 Temperature_Celsius	 0x0022   116   106   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   200   200   000	Old_age   Offline	  -	   0

No Errors Logged

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



########## SMART status report for ada2 drive (Western Digital Red: WD-WMC300411588) ##########

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   181   173   021	Pre-fail  Always	   -	   3916
  4 Start_Stop_Count		0x0032   100   100   000	Old_age   Always	   -	   473
  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   051   051   000	Old_age   Always	   -	   36304
10 Spin_Retry_Count		0x0032   100   100   000	Old_age   Always	   -	   0
11 Calibration_Retry_Count 0x0032   100   100   000	Old_age   Always	   -	   0
12 Power_Cycle_Count	   0x0032   100   100   000	Old_age   Always	   -	   230
192 Power-Off_Retract_Count 0x0032   200   200   000	Old_age   Always	   -	   116
193 Load_Cycle_Count		0x0032   200   200   000	Old_age   Always	   -	   356
194 Temperature_Celsius	 0x0022   116   105   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   200   200   000	Old_age   Offline	  -	   0

No Errors Logged

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



########## SMART status report for ada3 drive (Western Digital Red: WD-WMC300411516) ##########

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	   -	   31
  3 Spin_Up_Time			0x0027   181   174   021	Pre-fail  Always	   -	   3941
  4 Start_Stop_Count		0x0032   100   100   000	Old_age   Always	   -	   481
  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   051   051   000	Old_age   Always	   -	   36308
10 Spin_Retry_Count		0x0032   100   100   000	Old_age   Always	   -	   0
11 Calibration_Retry_Count 0x0032   100   100   000	Old_age   Always	   -	   0
12 Power_Cycle_Count	   0x0032   100   100   000	Old_age   Always	   -	   231
192 Power-Off_Retract_Count 0x0032   200   200   000	Old_age   Always	   -	   116
193 Load_Cycle_Count		0x0032   200   200   000	Old_age   Always	   -	   364
194 Temperature_Celsius	 0x0022   116   107   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   200   200   000	Old_age   Offline	  -	   0

No Errors Logged

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



########## SMART status report for ada4 drive (Western Digital Red: WD-WMC300412480) ##########

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   175   172   021	Pre-fail  Always	   -	   4225
  4 Start_Stop_Count		0x0032   100   100   000	Old_age   Always	   -	   469
  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   051   051   000	Old_age   Always	   -	   36288
10 Spin_Retry_Count		0x0032   100   100   000	Old_age   Always	   -	   0
11 Calibration_Retry_Count 0x0032   100   100   000	Old_age   Always	   -	   0
12 Power_Cycle_Count	   0x0032   100   100   000	Old_age   Always	   -	   229
192 Power-Off_Retract_Count 0x0032   200   200   000	Old_age   Always	   -	   116
193 Load_Cycle_Count		0x0032   200   200   000	Old_age   Always	   -	   562
194 Temperature_Celsius	 0x0022   115   103   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   200   200   000	Old_age   Offline	  -	   0

No Errors Logged

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



########## SMART status report for ada5 drive (Western Digital Red: WD-WMC300410673) ##########

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   180   172   021	Pre-fail  Always	   -	   4000
  4 Start_Stop_Count		0x0032   100   100   000	Old_age   Always	   -	   484
  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   051   051   000	Old_age   Always	   -	   36312
10 Spin_Retry_Count		0x0032   100   100   000	Old_age   Always	   -	   0
11 Calibration_Retry_Count 0x0032   100   100   000	Old_age   Always	   -	   0
12 Power_Cycle_Count	   0x0032   100   100   000	Old_age   Always	   -	   233
192 Power-Off_Retract_Count 0x0032   200   200   000	Old_age   Always	   -	   117
193 Load_Cycle_Count		0x0032   200   200   000	Old_age   Always	   -	   366
194 Temperature_Celsius	 0x0022   114   103   000	Old_age   Always	   -	   33
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   200   200   000	Old_age   Offline	  -	   0

No Errors Logged

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

Hello,

I've been attemping to get this script above to run but have had no luck thus far. I am using the script as seen in the "code" section of this post and have added my own email address to it. The script itself is located in my home directory under a folder named "scripts". I have added execute perms and made "root:wheel" the owners of it.

When I run ./myscript.sh there is a brief pause as if its doing something but no data is returned either on the screen on via an email.

Any ideas?

Thanks
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
For got to mention that I've also tried running it via sudo with the same results..Thanks
FWIW, I run my SMART report script using Bash, so the shebang is different, i.e.:
Code:
#!/bin/bash
instead of
Code:
#!/bin/sh
Does your report file ("/tmp/smart_report.tmp") contain the email header information that's supposed to be emitted by the script?

And lastly -- I almost hate to ask; please don't be offended! -- do you have a working email account set up under System->Email? Because AFAIK this is the email account used by sendmail.
 

StorageEater

Dabbler
Joined
Sep 17, 2016
Messages
10
FWIW, I run my SMART report script using Bash, so the shebang is different, i.e.:
Code:
#!/bin/bash
instead of
Code:
#!/bin/sh
Does your report file ("/tmp/smart_report.tmp") contain the email header information that's supposed to be emitted by the script?

And lastly -- I almost hate to ask; please don't be offended! -- do you have a working email account set up under System->Email? Because AFAIK this is the email account used by sendmail.

Hello and thanks for your reply.

The funny thing is that I don't see a report file showing up at all in the /tmp directory which is probably part of the issue but I wasn't certain if that gets removed immediately or not when the script runs.

I can try changing the shebang and see how it goes.

It all good, I figured I would be asked about the email functionality due to me forgetting to mention that the standard "test" option works fine within the email setup page.

Is the expected behavior of running the script via the ./xyz.sh from within the terminal that an output will appear within that window or will it do nothing and just send a message via email?
 
Top