Issue with SMART Scripts

adrianwi

Guru
Joined
Oct 15, 2013
Messages
1,231
I'm struggling with the SMART scripts for my new FreeNAS build, and I'm struggling to work out where I'm going wrong. They are working fine on my old build!

So I pretty much edited my old script, which I think came from this thread for the new build, including the extra drives

Code:
removed script as too many characters


I run it with a Task in the GUI, which was working and sending me an e-mail, but most of the output was blank

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

+------+---------------+----+-----+-----+-----+-------+-------+--------+------+----------+------+-------+
|Device|Serial         |Temp|Power|Start|Spin |ReAlloc|Current|Offline |Seek  |Total     |High  |Cmd    |
|      |               |    |On   |Stop |Retry|Sectors|Pending|Uncorrec|Errors|Seeks     |Fly   |Timeout|
|      |               |    |Hours|Count|Count|       |Sectors|Sectors |      |          |Writes|Count  |
+------+---------------+----+-----+-----+-----+-------+-------+--------+------+----------+------+-------+
|da0   |JEHGA27N       | 29 |  995|   24|    0|      0|      0|       0|   N/A|       N/A|   N/A|    N/A|
|da1   |2SG8ZMWJ       | 30 |  993|   15|    0|      0|      0|       0|   N/A|       N/A|   N/A|    N/A|
|da2   |1EGB8B3Z       | 32 |  995|   24|    0|      0|      0|       0|   N/A|       N/A|   N/A|    N/A|
|da3   |2SG4TEYW       | 28 |  993|   10|    0|      0|      0|       0|   N/A|       N/A|   N/A|    N/A|
|da4   |2YKLJ44D       | 27 |  993|   11|    0|      0|      0|       0|   N/A|       N/A|   N/A|    N/A|
|da5   |1EG7R5BZ       | 29 |  993|   12|    0|      0|      0|       0|   N/A|       N/A|   N/A|    N/A|
|da6   |1EG0U39Z       | 30 |  995|   24|    0|      0|      0|       0|   N/A|       N/A|   N/A|    N/A|
|da7   |1EG3GAUZ       | 29 |  993|   12|    0|      0|      0|       0|   N/A|       N/A|   N/A|    N/A|
|ada1  |1944E3D298A4   | 30 | 1002|     |     |       |      0|       0|   N/A|       N/A|   N/A|    N/A|
|ada0  |1944E3D28904   | 32 | 1009|     |     |       |      0|       0|   N/A|       N/A|   N/A|    N/A|
+------+---------------+----+-----+-----+-----+-------+-------+--------+------+----------+------+-------+



########## SMART status report for da0 drive (WDC HGST Ultrastar: JEHGA27N) ##########
smartctl 6.6 2017-11-05 r4594 [FreeBSD 11.2-STABLE amd64] (local build)

SMART overall-health self-assessment test result: PASSED

ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x000b   100   100   016    Pre-fail  Always       -       0
  2 Throughput_Performance  0x0004   128   128   054    Old_age   Offline      -       116
  3 Spin_Up_Time            0x0007   162   162   024    Pre-fail  Always       -       439 (Average 372)
  4 Start_Stop_Count        0x0012   100   100   000    Old_age   Always       -       24
  5 Reallocated_Sector_Ct   0x0033   100   100   005    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x000a   100   100   067    Old_age   Always       -       0
  8 Seek_Time_Performance   0x0004   128   128   020    Old_age   Offline      -       18
  9 Power_On_Hours          0x0012   100   100   000    Old_age   Always       -       995
 10 Spin_Retry_Count        0x0012   100   100   060    Old_age   Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       24
 22 Helium_Level            0x0023   100   100   025    Pre-fail  Always       -       100
192 Power-Off_Retract_Count 0x0032   100   100   000    Old_age   Always       -       58
193 Load_Cycle_Count        0x0012   100   100   000    Old_age   Always       -       58
194 Temperature_Celsius     0x0002   224   224   000    Old_age   Always       -       29 (Min/Max 18/33)
196 Reallocated_Event_Count 0x0032   100   100   000    Old_age   Always       -       0
197 Current_Pending_Sector  0x0022   100   100   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0008   100   100   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x000a   200   200   000    Old_age   Always       -       0

No Errors Logged

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



########## SMART status report for da1 drive (WDC HGST Ultrastar: 2SG8ZMWJ) ##########
smartctl 6.6 2017-11-05 r4594 [FreeBSD 11.2-STABLE amd64] (local build)

SMART overall-health self-assessment test result: PASSED

ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x000b   100   100   016    Pre-fail  Always       -       0
  2 Throughput_Performance  0x0004   126   126   054    Old_age   Offline      -       124
  3 Spin_Up_Time            0x0007   154   154   024    Pre-fail  Always       -       443 (Average 413)
  4 Start_Stop_Count        0x0012   100   100   000    Old_age   Always       -       15
  5 Reallocated_Sector_Ct   0x0033   100   100   005    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x000a   100   100   067    Old_age   Always       -       0
  8 Seek_Time_Performance   0x0004   128   128   020    Old_age   Offline      -       18
  9 Power_On_Hours          0x0012   100   100   000    Old_age   Always       -       993
 10 Spin_Retry_Count        0x0012   100   100   060    Old_age   Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       15
 22 Helium_Level            0x0023   100   100   025    Pre-fail  Always       -       100
192 Power-Off_Retract_Count 0x0032   100   100   000    Old_age   Always       -       49
193 Load_Cycle_Count        0x0012   100   100   000    Old_age   Always       -       49
194 Temperature_Celsius     0x0002   216   216   000    Old_age   Always       -       30 (Min/Max 21/35)
196 Reallocated_Event_Count 0x0032   100   100   000    Old_age   Always       -       0
197 Current_Pending_Sector  0x0022   100   100   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0008   100   100   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x000a   200   200   000    Old_age   Always       -       0

No Errors Logged

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



########## SMART status report for da2 drive (WDC HGST Ultrastar: 1EGB8B3Z) ##########
smartctl 6.6 2017-11-05 r4594 [FreeBSD 11.2-STABLE amd64] (local build)

SMART overall-health self-assessment test result: PASSED

ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x000b   100   100   016    Pre-fail  Always       -       0
  2 Throughput_Performance  0x0004   128   128   054    Old_age   Offline      -       116
  3 Spin_Up_Time            0x0007   166   166   024    Pre-fail  Always       -       436 (Average 356)
  4 Start_Stop_Count        0x0012   100   100   000    Old_age   Always       -       24
  5 Reallocated_Sector_Ct   0x0033   100   100   005    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x000a   100   100   067    Old_age   Always       -       0
  8 Seek_Time_Performance   0x0004   128   128   020    Old_age   Offline      -       18
  9 Power_On_Hours          0x0012   100   100   000    Old_age   Always       -       995
 10 Spin_Retry_Count        0x0012   100   100   060    Old_age   Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       24
 22 Helium_Level            0x0023   100   100   025    Pre-fail  Always       -       100
192 Power-Off_Retract_Count 0x0032   100   100   000    Old_age   Always       -       58
193 Load_Cycle_Count        0x0012   100   100   000    Old_age   Always       -       58
194 Temperature_Celsius     0x0002   203   203   000    Old_age   Always       -       32 (Min/Max 17/37)
196 Reallocated_Event_Count 0x0032   100   100   000    Old_age   Always       -       0
197 Current_Pending_Sector  0x0022   100   100   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0008   100   100   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x000a   200   200   000    Old_age   Always       -       0

No Errors Logged

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



########## SMART status report for da3 drive (WDC HGST Ultrastar: 2SG4TEYW) ##########
smartctl 6.6 2017-11-05 r4594 [FreeBSD 11.2-STABLE amd64] (local build)

SMART overall-health self-assessment test result: PASSED

ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x000b   100   100   016    Pre-fail  Always       -       0
  2 Throughput_Performance  0x0004   129   129   054    Old_age   Offline      -       112
  3 Spin_Up_Time            0x0007   163   163   024    Pre-fail  Always       -       441 (Average 365)
  4 Start_Stop_Count        0x0012   100   100   000    Old_age   Always       -       10
  5 Reallocated_Sector_Ct   0x0033   100   100   005    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x000a   100   100   067    Old_age   Always       -       0
  8 Seek_Time_Performance   0x0004   128   128   020    Old_age   Offline      -       18
  9 Power_On_Hours          0x0012   100   100   000    Old_age   Always       -       993
 10 Spin_Retry_Count        0x0012   100   100   060    Old_age   Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       10
 22 Helium_Level            0x0023   100   100   025    Pre-fail  Always       -       100
192 Power-Off_Retract_Count 0x0032   100   100   000    Old_age   Always       -       44
193 Load_Cycle_Count        0x0012   100   100   000    Old_age   Always       -       44
194 Temperature_Celsius     0x0002   232   232   000    Old_age   Always       -       28 (Min/Max 21/33)
196 Reallocated_Event_Count 0x0032   100   100   000    Old_age   Always       -       0
197 Current_Pending_Sector  0x0022   100   100   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0008   100   100   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x000a   200   200   000    Old_age   Always       -       0

No Errors Logged

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



########## SMART status report for da4 drive (WDC HGST Ultrastar: 2YKLJ44D) ##########
smartctl 6.6 2017-11-05 r4594 [FreeBSD 11.2-STABLE amd64] (local build)

SMART overall-health self-assessment test result: PASSED

ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x000b   100   100   016    Pre-fail  Always       -       0
  2 Throughput_Performance  0x0004   128   128   054    Old_age   Offline      -       116
  3 Spin_Up_Time            0x0007   177   177   024    Pre-fail  Always       -       443 (Average 299)
  4 Start_Stop_Count        0x0012   100   100   000    Old_age   Always       -       11
  5 Reallocated_Sector_Ct   0x0033   100   100   005    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x000a   100   100   067    Old_age   Always       -       0
  8 Seek_Time_Performance   0x0004   128   128   020    Old_age   Offline      -       18
  9 Power_On_Hours          0x0012   100   100   000    Old_age   Always       -       993
 10 Spin_Retry_Count        0x0012   100   100   060    Old_age   Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       11
 22 Helium_Level            0x0023   100   100   025    Pre-fail  Always       -       100
192 Power-Off_Retract_Count 0x0032   100   100   000    Old_age   Always       -       44
193 Load_Cycle_Count        0x0012   100   100   000    Old_age   Always       -       44
194 Temperature_Celsius     0x0002   240   240   000    Old_age   Always       -       27 (Min/Max 20/31)
196 Reallocated_Event_Count 0x0032   100   100   000    Old_age   Always       -       0
197 Current_Pending_Sector  0x0022   100   100   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0008   100   100   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x000a   200   200   000    Old_age   Always       -       0

No Errors Logged

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



########## SMART status report for da5 drive (WDC HGST Ultrastar: 1EG7R5BZ) ##########
smartctl 6.6 2017-11-05 r4594 [FreeBSD 11.2-STABLE amd64] (local build)

SMART overall-health self-assessment test result: PASSED

ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x000b   100   100   016    Pre-fail  Always       -       0
  2 Throughput_Performance  0x0004   128   128   054    Old_age   Offline      -       116
  3 Spin_Up_Time            0x0007   162   162   024    Pre-fail  Always       -       442 (Average 369)
  4 Start_Stop_Count        0x0012   100   100   000    Old_age   Always       -       12
  5 Reallocated_Sector_Ct   0x0033   100   100   005    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x000a   100   100   067    Old_age   Always       -       0
  8 Seek_Time_Performance   0x0004   128   128   020    Old_age   Offline      -       18
  9 Power_On_Hours          0x0012   100   100   000    Old_age   Always       -       993
 10 Spin_Retry_Count        0x0012   100   100   060    Old_age   Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       12
 22 Helium_Level            0x0023   100   100   025    Pre-fail  Always       -       100
192 Power-Off_Retract_Count 0x0032   100   100   000    Old_age   Always       -       45
193 Load_Cycle_Count        0x0012   100   100   000    Old_age   Always       -       45
194 Temperature_Celsius     0x0002   224   224   000    Old_age   Always       -       29 (Min/Max 21/33)
196 Reallocated_Event_Count 0x0032   100   100   000    Old_age   Always       -       0
197 Current_Pending_Sector  0x0022   100   100   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0008   100   100   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x000a   200   200   000    Old_age   Always       -       0

No Errors Logged

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



########## SMART status report for da6 drive (WDC HGST Ultrastar: 1EG0U39Z) ##########
smartctl 6.6 2017-11-05 r4594 [FreeBSD 11.2-STABLE amd64] (local build)

SMART overall-health self-assessment test result: PASSED

ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x000b   100   100   016    Pre-fail  Always       -       0
  2 Throughput_Performance  0x0004   127   127   054    Old_age   Offline      -       120
  3 Spin_Up_Time            0x0007   162   162   024    Pre-fail  Always       -       437 (Average 373)
  4 Start_Stop_Count        0x0012   100   100   000    Old_age   Always       -       24
  5 Reallocated_Sector_Ct   0x0033   100   100   005    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x000a   100   100   067    Old_age   Always       -       0
  8 Seek_Time_Performance   0x0004   128   128   020    Old_age   Offline      -       18
  9 Power_On_Hours          0x0012   100   100   000    Old_age   Always       -       995
 10 Spin_Retry_Count        0x0012   100   100   060    Old_age   Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       24
 22 Helium_Level            0x0023   100   100   025    Pre-fail  Always       -       100
192 Power-Off_Retract_Count 0x0032   100   100   000    Old_age   Always       -       59
193 Load_Cycle_Count        0x0012   100   100   000    Old_age   Always       -       59
194 Temperature_Celsius     0x0002   216   216   000    Old_age   Always       -       30 (Min/Max 17/35)
196 Reallocated_Event_Count 0x0032   100   100   000    Old_age   Always       -       0
197 Current_Pending_Sector  0x0022   100   100   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0008   100   100   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x000a   200   200   000    Old_age   Always       -       0

No Errors Logged

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



########## SMART status report for da7 drive (WDC HGST Ultrastar: 1EG3GAUZ) ##########
smartctl 6.6 2017-11-05 r4594 [FreeBSD 11.2-STABLE amd64] (local build)

SMART overall-health self-assessment test result: PASSED

ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x000b   100   100   016    Pre-fail  Always       -       0
  2 Throughput_Performance  0x0004   128   128   054    Old_age   Offline      -       116
  3 Spin_Up_Time            0x0007   169   169   024    Pre-fail  Always       -       429 (Average 350)
  4 Start_Stop_Count        0x0012   100   100   000    Old_age   Always       -       12
  5 Reallocated_Sector_Ct   0x0033   100   100   005    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x000a   100   100   067    Old_age   Always       -       0
  8 Seek_Time_Performance   0x0004   128   128   020    Old_age   Offline      -       18
  9 Power_On_Hours          0x0012   100   100   000    Old_age   Always       -       993
 10 Spin_Retry_Count        0x0012   100   100   060    Old_age   Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       12
 22 Helium_Level            0x0023   100   100   025    Pre-fail  Always       -       100
192 Power-Off_Retract_Count 0x0032   100   100   000    Old_age   Always       -       46
193 Load_Cycle_Count        0x0012   100   100   000    Old_age   Always       -       46
194 Temperature_Celsius     0x0002   224   224   000    Old_age   Always       -       29 (Min/Max 20/34)
196 Reallocated_Event_Count 0x0032   100   100   000    Old_age   Always       -       0
197 Current_Pending_Sector  0x0022   100   100   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0008   100   100   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x000a   200   200   000    Old_age   Always       -       0

No Errors Logged

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



########## SMART status report for ada1 drive (Crucial/Micron BX/MX1/2/3/500, M5/600,: 1944E3D298A4) ##########
smartctl 6.6 2017-11-05 r4594 [FreeBSD 11.2-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   100   100   050    Pre-fail  Always       -       0
  5 Reallocate_NAND_Blk_Cnt 0x0032   100   100   010    Old_age   Always       -       0
  9 Power_On_Hours          0x0032   100   100   050    Old_age   Always       -       1002
 12 Power_Cycle_Count       0x0032   100   100   050    Old_age   Always       -       22
171 Program_Fail_Count      0x0032   100   100   050    Old_age   Always       -       0
172 Erase_Fail_Count        0x0032   100   100   050    Old_age   Always       -       0
173 Ave_Block-Erase_Count   0x0032   100   100   050    Old_age   Always       -       0
174 Unexpect_Power_Loss_Ct  0x0032   100   100   050    Old_age   Always       -       17
180 Unused_Reserve_NAND_Blk 0x0032   100   100   050    Old_age   Always       -       100
183 SATA_Interfac_Downshift 0x0032   100   100   050    Old_age   Always       -       0
184 Error_Correction_Count  0x0032   100   100   050    Old_age   Always       -       0
187 Reported_Uncorrect      0x0032   100   100   050    Old_age   Always       -       0
194 Temperature_Celsius     0x0022   070   060   050    Old_age   Always       -       30 (Min/Max 29/40)
196 Reallocated_Event_Count 0x0032   100   100   050    Old_age   Always       -       0
197 Current_Pending_Sector  0x0032   100   100   050    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0030   100   100   050    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x0032   100   100   050    Old_age   Always       -       0
202 Percent_Lifetime_Remain 0x0030   100   100   001    Old_age   Offline      -       100
206 Write_Error_Rate        0x002e   100   100   050    Old_age   Always       -       0
210 Success_RAIN_Recov_Cnt  0x0032   100   100   050    Old_age   Always       -       0
246 Total_LBAs_Written      0x0032   100   100   050    Old_age   Always       -       6648492
247 Host_Program_Page_Count 0x0032   100   100   050    Old_age   Always       -       207765
248 FTL_Program_Page_Count  0x0032   100   100   050    Old_age   Always       -       0

No Errors Logged

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



########## SMART status report for ada0 drive (Crucial/Micron BX/MX1/2/3/500, M5/600,: 1944E3D28904) ##########
smartctl 6.6 2017-11-05 r4594 [FreeBSD 11.2-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   100   100   050    Pre-fail  Always       -       0
  5 Reallocate_NAND_Blk_Cnt 0x0032   100   100   010    Old_age   Always       -       0
  9 Power_On_Hours          0x0032   100   100   050    Old_age   Always       -       1009
 12 Power_Cycle_Count       0x0032   100   100   050    Old_age   Always       -       22
171 Program_Fail_Count      0x0032   100   100   050    Old_age   Always       -       0
172 Erase_Fail_Count        0x0032   100   100   050    Old_age   Always       -       0
173 Ave_Block-Erase_Count   0x0032   100   100   050    Old_age   Always       -       1
174 Unexpect_Power_Loss_Ct  0x0032   100   100   050    Old_age   Always       -       14
180 Unused_Reserve_NAND_Blk 0x0032   100   100   050    Old_age   Always       -       100
183 SATA_Interfac_Downshift 0x0032   100   100   050    Old_age   Always       -       0
184 Error_Correction_Count  0x0032   100   100   050    Old_age   Always       -       0
187 Reported_Uncorrect      0x0032   100   100   050    Old_age   Always       -       0
194 Temperature_Celsius     0x0022   068   059   050    Old_age   Always       -       32 (Min/Max 30/41)
196 Reallocated_Event_Count 0x0032   100   100   050    Old_age   Always       -       0
197 Current_Pending_Sector  0x0032   100   100   050    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0030   100   100   050    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x0032   100   100   050    Old_age   Always       -       0
202 Percent_Lifetime_Remain 0x0030   100   100   001    Old_age   Offline      -       100
206 Write_Error_Rate        0x002e   100   100   050    Old_age   Always       -       0
210 Success_RAIN_Recov_Cnt  0x0032   100   100   050    Old_age   Always       -       0
246 Total_LBAs_Written      0x0032   100   100   050    Old_age   Always       -       57571225
247 Host_Program_Page_Count 0x0032   100   100   050    Old_age   Always       -       1799100
248 FTL_Program_Page_Count  0x0032   100   100   050    Old_age   Always       -       0

No Errors Logged

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


I went back and had a look at the thread, and noticed there were different scripts for SAS and SATA. All of my drives are SATA drives, but some are connected via the SAS controller on the motherboard, so wasn't sure if they needed to use the SAS script?

I set-up two different scripts (one for SATA and one for SAS) but neither of these is even sending the e-mail when I run it in the GUI or command line.

Code:
#!/bin/sh

### Parameters ###
logfile="/tmp/smart_report.tmp"
email="freenas0@domain.com"
subject="SMART Status Report for FreeNAS0"
drives="da0 da1 da2 da3 da4 da5 da6 da7 da8 ada0 ada1 ada2 ada3"
tempWarn=40
tempCrit=45
sectorsCrit=10
testAgeWarn=1
warnSymbol="?"
critSymbol="!"

### Set email headers ###
(
    echo "To: ${email}"
    echo "Subject: ${subject}"
    echo "Content-Type: text/html"
    echo "MIME-Version: 1.0"
    echo -e "\r\n"
) > "$logfile"

### Set email body ###
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"


Any ideas what I'm doing wrong?

Thanks
 

Alecmascot

Guru
Joined
Mar 18, 2014
Messages
1,175
11.3 ?
 

adrianwi

Guru
Joined
Oct 15, 2013
Messages
1,231
11.2-U7
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
Couple of things to try;

1> Make sure the /tmp directory exists and you have write privileges on it
2> Comment out the last line of your script by putting an # before the 'rm' command. The script will no longer delete the log file. Run your script, then look at /tmp/smart_report.tmp with a text editor and go from there...
 
Top