Github repository for FreeNAS scripts, including disk burnin and rsync support

Github repository for FreeNAS scripts, including disk burnin and rsync support

devnullius

Patron
Joined
Dec 9, 2015
Messages
289
Thanks. Any idea though how to do it with git?
 

Ericloewe

Server Wrangler
Moderator
Joined
Feb 15, 2014
Messages
20,176
You don't need git, just go to the repository's web page on github.com.

If you want to use git, it's the exact same process as it would be on FreeNAS, but on your client. Then you just copy the files over.
 

MorkaiTheWolf

Dabbler
Joined
Aug 8, 2018
Messages
32
Not sure if this is appropriate to post here but I loved the burn in script and wanted to report some weirdness (Maybe? unless I messed something up) I encountered running these on my 10TB WD Reds. Short SMART tests and badblocks ran fine but when it ran the long test, it seemed to not actually run.
Here is the snippet of the log from where it appeared to try to start, slept for 0 seconds then says it completed:
Code:
+ Run SMART extended test on drive /dev/da2: Tue Oct  9 23:05:26 CDT 2018
+-----------------------------------------------------------------------------
Extended test started, sleeping 0 seconds until it finishes
Timeout polling for SMART self-test status
smartctl 6.6 2017-11-05 r4594 [FreeBSD 11.1-STABLE amd64] (local build)

SMART Self-test log structure revision number 1
Num  Test_Description	Status				  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Short offline	   Completed without error	   00%	   118		 -

Finished SMART extended test on drive /dev/da2: Wed Oct 10 03:08:20 CDT 2018

Is there anything I can test to assist in this? Not sure how to check this but I would like to help.
I did check the drive to see if it actually performed the test and it appears it did:
Code:
smartctl -l selftest /dev/da2
smartctl 6.6 2017-11-05 r4594 [FreeBSD 11.1-STABLE amd64] (local build)
Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF READ SMART DATA SECTION ===
SMART Self-test log structure revision number 1
Num  Test_Description	Status				  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Extended offline	Completed without error	   00%	   252		 -
# 2  Short offline	   Completed without error	   00%	   118		 -


Worth noting that in the script, it shows the last update is from June 8th, 2017 (from here: https://github.com/Spearfoot/disk-burnin-and-testing)
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
Not sure if this is appropriate to post here but I loved the burn in script and wanted to report some weirdness (Maybe? unless I messed something up) I encountered running these on my 10TB WD Reds. Short SMART tests and badblocks ran fine but when it ran the long test, it seemed to not actually run.
Here is the snippet of the log from where it appeared to try to start, slept for 0 seconds then says it completed:
Code:
+ Run SMART extended test on drive /dev/da2: Tue Oct  9 23:05:26 CDT 2018
+-----------------------------------------------------------------------------
Extended test started, sleeping 0 seconds until it finishes
Timeout polling for SMART self-test status
smartctl 6.6 2017-11-05 r4594 [FreeBSD 11.1-STABLE amd64] (local build)

SMART Self-test log structure revision number 1
Num  Test_Description	Status				  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Short offline	   Completed without error	   00%	   118		 -

Finished SMART extended test on drive /dev/da2: Wed Oct 10 03:08:20 CDT 2018

Is there anything I can test to assist in this? Not sure how to check this but I would like to help.
I did check the drive to see if it actually performed the test and it appears it did:
Code:
smartctl -l selftest /dev/da2
smartctl 6.6 2017-11-05 r4594 [FreeBSD 11.1-STABLE amd64] (local build)
Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF READ SMART DATA SECTION ===
SMART Self-test log structure revision number 1
Num  Test_Description	Status				  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Extended offline	Completed without error	   00%	   252		 -
# 2  Short offline	   Completed without error	   00%	   118		 -


Worth noting that in the script, it shows the last update is from June 8th, 2017 (from here: https://github.com/Spearfoot/disk-burnin-and-testing)
I've never tested the script with such large disks... Lucky you!

It may have something to do with how smartctl displays the device's estimated test durations. Sometimes, especially for larger drives, this is returned as 'hours+minutes' instead of a simple integer number of minutes -- which probably breaks my parsing code. If you will show the output of the smartctl -c /dev/da2 command, this will tell us what's what. We're interested in the "Extended self-test routine recommended polling time" value.
 

MorkaiTheWolf

Dabbler
Joined
Aug 8, 2018
Messages
32
I've never tested the script with such large disks... Lucky you!

It may have something to do with how smartctl displays the device's estimated test durations. Sometimes, especially for larger drives, this is returned as 'hours+minutes' instead of a simple integer number of minutes -- which probably breaks my parsing code. If you will show the output of the smartctl -c /dev/da2 command, this will tell us what's what. We're interested in the "Extended self-test routine recommended polling time" value.

I will say I stumbled on a damn fine deal for the drives that I couldn't pass up. :D

As per your request, here is the value for the "extended self-test routine recommended polling time":
Code:
Extended self-test routine
recommended polling time:		(1226) minutes.

Thinking on this some more, these were brand new drives before I tried to run the burn in script on them. Is it possible that since a smart self-test was never done on them before hand, there was no polling time already noted on the drive?
 
Last edited:

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080
Worth noting that in the script, it shows the last update is from June 8th, 2017
There shouldn't be a lot of reasons to edit the script. This is one of the few. The polling time value might just be out of range / larger than what the script is looking for. The time it takes to run the test increases with drive size, so it will probably need a revision to accommodate larger drives.
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
I will say I stumbled on a damn fine deal for the drives that I couldn't pass up. :D

As per your request, here is the value for the "extended self-test routine recommended polling time":
Code:
Extended self-test routine
recommended polling time:		(1226) minutes.

Thinking on this some more, these were brand new drives before I tried to run the burn in script on them. Is it possible that since a smart self-test was never done on them before hand, there was no polling time already noted on the drive?
Been busy lately and only just now had a chance to look into this...

At first I thought that we might have a simple 32-bit integer overflow, as suggested by @Chris Moore -- because 1226 minutes * 60 minutes/second = 73,560 seconds, and 73,560 > 2**32. But a few simple shell tests ruled out that possibility, and the sleep command seems perfectly willing to sleep for 73,560 seconds.

So we're going to have to dig deeper.

May I ask you to do the following? Edit your copy of disk-burnin.sh and set the Dry_Run variable to a non-zero thus: Dry_Run=1. Run this script against one of your huge drives, e.g., ./disk-burnin-sh da2. Because we're doing a 'dry run', this won't actually run any tests against your drive, but it will generate a log showing what would happen during a normal run. The first chunk of this log is what I'd like to see, as it will tell us the sleep durations in both seconds and minutes, for both the short and long tests. Post it here, in code blocks, and we'll go from there.

Here is the relevant log chunk from a 'dry run' against one of my tiny 6TB disks:
Code:
+-----------------------------------------------------------------------------
+ Started burn-in of /dev/da7 : Wed Oct 31 19:16:13 CDT 2018
+-----------------------------------------------------------------------------
Host: bandit.spearfoot.net
Drive Model: WDC_WD6001FZWX-00A2VA0
Serial Number: WD-XXXXXXXXXXXX
Short test duration: 2 minutes
Short test sleep duration: 120 seconds
Extended test duration: 579 minutes
Extended test sleep duration: 34740 seconds
Log file: ./burnin-WDC_WD6001FZWX-00A2VA0_WD-XXXXXXXXXXXX.log
Bad blocks file: ./burnin-WDC_WD6001FZWX-00A2VA0_WD-XXXXXXXXXXXX.bb
+-----------------------------------------------------------------------------
+ Run SMART short test on drive /dev/da7: Wed Oct 31 19:16:13 CDT 2018
+-----------------------------------------------------------------------------
Dry run: would start the SMART short test and sleep 120 seconds until the test finishes
Finished SMART short test on drive /dev/da7: Wed Oct 31 19:16:13 CDT 2018
+-----------------------------------------------------------------------------
+ Run badblocks test on drive /dev/da7: Wed Oct 31 19:16:13 CDT 2018
+-----------------------------------------------------------------------------
Dry run: would run badblocks -b 4096 -wsv -o ./burnin-WDC_WD6001FZWX-00A2VA0_WD-XXXXXXXXXXXX.bb /dev/da7
Finished badblocks test on drive /dev/da7: Wed Oct 31 19:16:13 CDT 2018
+-----------------------------------------------------------------------------
+ Run SMART short test on drive /dev/da7: Wed Oct 31 19:16:13 CDT 2018
+-----------------------------------------------------------------------------
Dry run: would start the SMART short test and sleep 120 seconds until the test finishes
Finished SMART short test on drive /dev/da7: Wed Oct 31 19:16:13 CDT 2018
+-----------------------------------------------------------------------------
+ Run SMART extended test on drive /dev/da7: Wed Oct 31 19:16:13 CDT 2018
+-----------------------------------------------------------------------------
Dry run: would start the SMART extended test and sleep 34740 seconds until the test finishes
Finished SMART extended test on drive /dev/da7: Wed Oct 31 19:16:13 CDT 2018
+-----------------------------------------------------------------------------
+ SMART information for drive /dev/da7: Wed Oct 31 19:16:13 CDT 2018
+-----------------------------------------------------------------------------
smartctl 6.6 2017-11-05 r4594 [FreeBSD 11.1-STABLE amd64] (local build)
 

MorkaiTheWolf

Dabbler
Joined
Aug 8, 2018
Messages
32
Not a problem, here are the results
Code:
+-----------------------------------------------------------------------------
+ Started burn-in of /dev/da2 : Wed Oct 31 20:11:55 CDT 2018
+-----------------------------------------------------------------------------
Host: freenas.local
Drive Model: WDC_WD100EZAZ-11TDBA0
Serial Number: 2YHTLYYD
Short test duration:  minutes
Short test sleep duration: 0 seconds
Extended test duration:  minutes
Extended test sleep duration: 0 seconds
Log file: ./burnin-WDC_WD100EZAZ-11TDBA0_2YHTLYYD.log
Bad blocks file: ./burnin-WDC_WD100EZAZ-11TDBA0_2YHTLYYD.bb
+-----------------------------------------------------------------------------
+ Run SMART short test on drive /dev/da2: Wed Oct 31 20:11:55 CDT 2018
+-----------------------------------------------------------------------------
Dry run: would start the SMART short test and sleep 0 seconds until the test finishes
Finished SMART short test on drive /dev/da2: Wed Oct 31 20:11:55 CDT 2018
+-----------------------------------------------------------------------------
+ Run SMART extended test on drive /dev/da2: Wed Oct 31 20:11:55 CDT 2018
+-----------------------------------------------------------------------------
Dry run: would start the SMART extended test and sleep 0 seconds until the test finishes
Finished SMART extended test on drive /dev/da2: Wed Oct 31 20:11:55 CDT 2018
+-----------------------------------------------------------------------------
+ Run badblocks test on drive /dev/da2: Wed Oct 31 20:11:55 CDT 2018
+-----------------------------------------------------------------------------
Dry run: would run badblocks -b 4096 -wsv -o ./burnin-WDC_WD100EZAZ-11TDBA0_2YHTLYYD.bb /dev/da2
Finished badblocks test on drive /dev/da2: Wed Oct 31 20:11:55 CDT 2018
+-----------------------------------------------------------------------------
+ Run SMART short test on drive /dev/da2: Wed Oct 31 20:11:55 CDT 2018
+-----------------------------------------------------------------------------
Dry run: would start the SMART short test and sleep 0 seconds until the test finishes
Finished SMART short test on drive /dev/da2: Wed Oct 31 20:11:55 CDT 2018
+-----------------------------------------------------------------------------
+ Run SMART extended test on drive /dev/da2: Wed Oct 31 20:11:55 CDT 2018
+-----------------------------------------------------------------------------
Dry run: would start the SMART extended test and sleep 0 seconds until the test finishes
Finished SMART extended test on drive /dev/da2: Wed Oct 31 20:11:55 CDT 2018
+-----------------------------------------------------------------------------
+ SMART information for drive /dev/da2: Wed Oct 31 20:11:55 CDT 2018
+-----------------------------------------------------------------------------
smartctl 6.6 2017-11-05 r4594 [FreeBSD 11.1-STABLE amd64] (local build)
Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
Not a problem, here are the results
Code:
+-----------------------------------------------------------------------------
+ Started burn-in of /dev/da2 : Wed Oct 31 20:11:55 CDT 2018
+-----------------------------------------------------------------------------
Host: freenas.local
Drive Model: WDC_WD100EZAZ-11TDBA0
Serial Number: 2YHTLYYD
Short test duration:  minutes
Short test sleep duration: 0 seconds
Extended test duration:  minutes
Extended test sleep duration: 0 seconds
Log file: ./burnin-WDC_WD100EZAZ-11TDBA0_2YHTLYYD.log
Bad blocks file: ./burnin-WDC_WD100EZAZ-11TDBA0_2YHTLYYD.bb
+-----------------------------------------------------------------------------
+ Run SMART short test on drive /dev/da2: Wed Oct 31 20:11:55 CDT 2018
+-----------------------------------------------------------------------------
Dry run: would start the SMART short test and sleep 0 seconds until the test finishes
Finished SMART short test on drive /dev/da2: Wed Oct 31 20:11:55 CDT 2018
+-----------------------------------------------------------------------------
+ Run SMART extended test on drive /dev/da2: Wed Oct 31 20:11:55 CDT 2018
+-----------------------------------------------------------------------------
Dry run: would start the SMART extended test and sleep 0 seconds until the test finishes
Finished SMART extended test on drive /dev/da2: Wed Oct 31 20:11:55 CDT 2018
+-----------------------------------------------------------------------------
+ Run badblocks test on drive /dev/da2: Wed Oct 31 20:11:55 CDT 2018
+-----------------------------------------------------------------------------
Dry run: would run badblocks -b 4096 -wsv -o ./burnin-WDC_WD100EZAZ-11TDBA0_2YHTLYYD.bb /dev/da2
Finished badblocks test on drive /dev/da2: Wed Oct 31 20:11:55 CDT 2018
+-----------------------------------------------------------------------------
+ Run SMART short test on drive /dev/da2: Wed Oct 31 20:11:55 CDT 2018
+-----------------------------------------------------------------------------
Dry run: would start the SMART short test and sleep 0 seconds until the test finishes
Finished SMART short test on drive /dev/da2: Wed Oct 31 20:11:55 CDT 2018
+-----------------------------------------------------------------------------
+ Run SMART extended test on drive /dev/da2: Wed Oct 31 20:11:55 CDT 2018
+-----------------------------------------------------------------------------
Dry run: would start the SMART extended test and sleep 0 seconds until the test finishes
Finished SMART extended test on drive /dev/da2: Wed Oct 31 20:11:55 CDT 2018
+-----------------------------------------------------------------------------
+ SMART information for drive /dev/da2: Wed Oct 31 20:11:55 CDT 2018
+-----------------------------------------------------------------------------
smartctl 6.6 2017-11-05 r4594 [FreeBSD 11.1-STABLE amd64] (local build)
Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org
Thank you very much.

This shows that we're getting blanks instead of digits when parsing the test durations: both of the test durations are zero! A bug somewhere...

Would you be so kind as to run smartctl -c /dev/da2 > spearfoot_info.txt? This will write all of the smartctl output into a file named 'spearfoot_info.txt'. You can, of course, use whatever filename you like; it really doesn't matter. If you'll post the file contents here (in code tags), I can use it to test the script's parsing code and see about finding and fixing the bug.

Thanks again.
 

MorkaiTheWolf

Dabbler
Joined
Aug 8, 2018
Messages
32
Done and done

Code:
smartctl 6.6 2017-11-05 r4594 [FreeBSD 11.1-STABLE amd64] (local build)
Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF READ SMART DATA SECTION ===
General SMART Values:
Offline data collection status:  (0x82)	Offline data collection activity
					was completed without error.
					Auto Offline Data Collection: Enabled.
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:		 (   93) seconds.
Offline data collection
capabilities:			 (0x5b) SMART execute Offline immediate.
					Auto Offline data collection on/off support.
					Suspend Offline collection upon new
					command.
					Offline surface scan supported.
					Self-test supported.
					No Conveyance Self-test supported.
					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:	 (1226) minutes.
SCT capabilities:			(0x003d)	SCT Status supported.
					SCT Error Recovery Control supported.
					SCT Feature Control supported.
					SCT Data Table supported.
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
Done and done

Code:
smartctl 6.6 2017-11-05 r4594 [FreeBSD 11.1-STABLE amd64] (local build)
Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF READ SMART DATA SECTION ===
General SMART Values:
Offline data collection status:  (0x82)	Offline data collection activity
					was completed without error.
					Auto Offline Data Collection: Enabled.
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:		 (   93) seconds.
Offline data collection
capabilities:			 (0x5b) SMART execute Offline immediate.
					Auto Offline data collection on/off support.
					Suspend Offline collection upon new
					command.
					Offline surface scan supported.
					Self-test supported.
					No Conveyance Self-test supported.
					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:	 (1226) minutes.
SCT capabilities:			(0x003d)	SCT Status supported.
					SCT Error Recovery Control supported.
					SCT Feature Control supported.
					SCT Data Table supported.
Curiouser and curioser...
I piped your file through the relevant code in the script:
Code:
Short_Test_Minutes=$(cat ./input.txt | pcregrep -M "Short self-test routine.*\n.*recommended polling time:" | sed -e 's/)//;s/(//' | awk '{print $4}' | tr -d '\n')

Extended_Test_Minutes=$(cat ./input.txt | pcregrep -M "Extended self-test routine.*\n.*recommended polling time:" | sed -e 's/)//;s/(//' | awk '{print $4}' | tr -d '\n')
And got the exact results I expected to get:
Code:
Short test duration: 2 minutes
Short test sleep duration: 120 seconds
Extended test duration: 1226 minutes
Extended test sleep duration: 73560 seconds
So now I wonder if perhaps your copy of the script is bonked in some way. Perhaps you've used a DOS/Windows text editor to edit it? This might introduce CR/LF newlines, which differ from what Unix-based systems expect.

The only way I see to proceed is to ensure nothing like this has happened to your script. Will you tar your copy of the script and send me the tarball via private message? The command tar -c -f script_tarball disk-burnin.sh should do the trick... then send me the file script_tarball. I'll take a look at your script and see how things stand.
 

MorkaiTheWolf

Dabbler
Joined
Aug 8, 2018
Messages
32
Interesting, I didn't even think about that. I'll shoot ya the message here in a few minutes. :)
 

Jatrabari

Contributor
Joined
Sep 23, 2017
Messages
100
I am not proficient yet with script language so I will ask from wiser people, how can I get more past SMART test results listed in the SMART report in this section? For example three previous tests would be enough.

Code:
SMART Self-test log structure revision number 1
Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Short offline       Completed without error       00%       118         -


Also SATADOM serials are longer that HDD ones, how can I align all the other columns?

Code:
########## SMART status report summary for all drives on server FREENAS ##########

+------+------------------+-----+-----+-----+-----+-------+-------+--------+------+---------+------+-------+----+
|Device|Serial            |Temp |Power|Start|Spin |ReAlloc|Current|Offline |Seek  |Total    |High  |Command|Last|
|      |Number            |     |On   |Stop |Retry|Sectors|Pending|Uncorrec|Errors|Seeks    |Fly   |Timeout|Test|
|      |                  |     |Hours|Count|Count|       |Sectors|Sectors |      |         |Writes|Count  |Age |
+------+------------------+-----+-----+-----+-----+-------+-------+--------+------+---------+------+-------+----+
|da0   |WD-************   | 30 |  486|  142|    0|      0|      0|       0|   N/A|      N/A|   N/A|    N/A|   1|
|da1 ? |WD-************   | 28 |  957|  142|    0|      0|      0|       0|   N/A|      N/A|   N/A|    N/A|  2*|
|da2 ? |WD-************   | 29 |  954|  142|    0|      0|      0|       0|   N/A|      N/A|   N/A|    N/A|  2*|
|da3 ? |WD-************   | 28 |  953|  142|    0|      0|      0|       0|   N/A|      N/A|   N/A|    N/A|  2*|
|da4 ? |WD-************   | 28 |  955|  142|    0|      0|      0|       0|   N/A|      N/A|   N/A|    N/A|  2*|
|da5 ? |WD-************   | 28 |  951|  142|    0|      0|      0|       0|   N/A|      N/A|   N/A|    N/A|  2*|
|da6   |WD-************   | 29 |  486|  140|    0|      0|      0|       0|   N/A|      N/A|   N/A|    N/A|   1|
|da7 ? |WD-************   | 28 |  599|   39|    0|      0|      0|       0|   N/A|      N/A|   N/A|    N/A|  2*|
|ada0 ?|5***************  | 32 |  148|     |     |      0|      0|        |   N/A|      N/A|   N/A|    N/A|  6*|
|ada1 ?|SMC*****************| 37 | 1077|     |     |      0|      0|       0|   N/A|      N/A|   N/A|    N/A| 45*|
|ada2 ?|SMC*****************| 40 | 1077|     |     |      0|      0|       0|   N/A|      N/A|   N/A|    N/A| 45*|
+------+------------------+-----+-----+-----+-----+-------+-------+--------+------+---------+------+-------+----+
 

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080
It looks like you need to run a short test daily on all your drives and a long test weekly. That should eliminate the question marks and asterisks.
 

Jatrabari

Contributor
Joined
Sep 23, 2017
Messages
100
It looks like you need to run a short test daily on all your drives and a long test weekly. That should eliminate the question marks and asterisks.

Why does it flag the test age so soon? I was wondering that...

But that isn't the problem. With the question marks Serial Number column is align perfectly with Device and Temp excluding SATADOMs. Asterisks in the last column don't affect the column width.
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
Why does it flag the test age so soon? I was wondering that...

But that isn't the problem. With the question marks Serial Number column is align perfectly with Device and Temp excluding SATADOMs. Asterisks in the last column don't affect the column width.
I've modifed the script to support 24-character serial numbers and committed the updated version to GitHub.
 

Jatrabari

Contributor
Joined
Sep 23, 2017
Messages
100
I've modifed the script to support 24-character serial numbers and committed the updated version to GitHub.

Thanks you for a quick fix, now it looks great.

I also solved the past SMART test result problem where I replaced this section

Code:
  echo "########## SMART status report for ${drive} drive (${brand}: ${serial}) ##########"
  "${smartctl}" -n never -H -A -l error /dev/"${drive}"
  "${smartctl}" -n never -l selftest /dev/"${drive}" | grep "# 1 \|Num" | cut -c6-
  ) >> ${logfile}

with this

Code:
  echo "########## SMART status report for ${drive} drive (${brand}: ${serial}) ##########"
  "${smartctl}" -n never -H -A -l error /dev/"${drive}"
  "${smartctl}" -n never -l selftest /dev/"${drive}" | grep "# 5 \|# 4 \|# 3 \|# 2 \|# 1 \|Num"
  ) >> ${logfile}

Now it will print 5 previous test results.
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
Thanks you for a quick fix, now it looks great.

I also solved the past SMART test result problem where I replaced this section

Code:
  echo "########## SMART status report for ${drive} drive (${brand}: ${serial}) ##########"
  "${smartctl}" -n never -H -A -l error /dev/"${drive}"
  "${smartctl}" -n never -l selftest /dev/"${drive}" | grep "# 1 \|Num" | cut -c6-
  ) >> ${logfile}

with this

Code:
  echo "########## SMART status report for ${drive} drive (${brand}: ${serial}) ##########"
  "${smartctl}" -n never -H -A -l error /dev/"${drive}"
  "${smartctl}" -n never -l selftest /dev/"${drive}" | grep "# 5 \|# 4 \|# 3 \|# 2 \|# 1 \|Num"
  ) >> ${logfile}

Now it will print 5 previous test results.
You can also use the smartctl 'xselftest' option to return the 'n' most recent test results. I haven't modified the script to use it because it a> may not work for all drives and b> may not be present in older versions of the program. Here is the call to return the 5 most recent test results:
Code:
root@bandit:~ # smartctl -n never -l xselftest,5 /dev/da4
smartctl 6.6 2017-11-05 r4594 [FreeBSD 11.1-STABLE amd64] (local build)
Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF READ SMART DATA SECTION ===
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%     14991         -
# 2  Short offline       Completed without error       00%     14967         -
# 3  Short offline       Completed without error       00%     14943         -
# 4  Short offline       Completed without error       00%     14919         -
# 5  Short offline       Completed without error       00%     14895         -
 

Soloam

Contributor
Joined
Feb 14, 2014
Messages
196
Hello, I've been using your scripts for some time, and one that is very useful is the save config! That saved me one or two times. Thank You. One thing that is missing in this script is the saving of the password seed, like in the save config from the GUI interface. That is very useful now with the cloud sync and also with ths SSH key (that I always have to re-import, probably because of this). When I save the config from the GUI, it creates a TAR file with the database and the password seed. Can this be replicated in the batch?

Thank You
 
Top