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

Stux

MVP
Joined
Jun 2, 2016
Messages
4,419
You have a great bit of code here. I got it working on both of my FreeNAS systems last night and took it into work with me this morning.
Unfortunately for me, the system I wanted to run this on that has no Internet access is CentOS and this script will not run on it because of the ''sysctl -n kern.disks". It there is no kern.disks in CentOS. I spent some time looking at it today but I have not done any bash scripting in over a decade and even when I was doing it, I never did anything this sophisticated.
CentOS has a directory /dev/disk/by-partid that appears to list only the disks in the zpool.

Well, kern.disks is a BSD kernel property. And CentOS is Linux.
 

adrianwi

Guru
Joined
Oct 15, 2013
Messages
1,231
I've been using these smart, zpool and ups scripts for ages without any problem. I have 2 FreeNAS machines, and run smart, zpool and ups on freenas1 and smart and zpool on freenas2.

Recently update from 9.3.1 to 9.10.1-U4 and other than having to copy the scripts back to the /etc folder from my temp dataset everything worked fine on freenas1. I'd done the same on freenas2, but at the scheduled time, only the zpool script ran and e-mailed successfully.

When I've compared the 2 scripts, other than the e-mail address and drives, there are no differences (freenas1 has most drives connected to da* and 2 on ada*, whereas freenas2 has them all on ada*)

Code:
#!/bin/sh

### Parameters ###
logfile="/tmp/smart_report.tmp"
email="freenas2@email.co.uk"
subject="SMART Status Report for freenas2"
drives="ada0 ada1 ada2 ada3 ada4"

### 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 |Seek  |Total	 |High  |Cmd	|"
	echo "|	  |			   |	|On   |Stop |Retry|Sectors|Pending|Uncorrec|Errors|Seeks	 |Fly   |Timeout|"
	echo "|	  |			   |	|Hours|Count|Count|	   |Sectors|Sectors |	  |		  |Writes|Count  |"
	echo "+------+---------------+----+-----+-----+-----+-------+-------+--------+------+----------+------+-------+"
) >> ${logfile}
for drive in $drives
do
	(
		(echo "device: ${drive}"; smartctl -v 7,hex48 -a /dev/${drive}) | awk '\
		/device:/{device=$2} \
		/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} \
		/Seek_Error_Rate/{seekErrors=("0x" substr($10,3,4));totalSeeks=("0x" substr($10,7))} \
		/High_Fly_Writes/{hiFlyWr=$10} \
		/Command_Timeout/{cmdTimeout=$10} \
		END {
			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|%10s|%6s|%7s|\n",
			device, serial, temp, onHours, startStop, spinRetry, reAlloc, pending, offlineUnc, seekErrors, totalSeeks, hiFlyWr, cmdTimeout;
		}'
	) >> ${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 -n never -H -A -l error /dev/${drive}
		smartctl -n never -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}

When I run it from the shell, it displays this:

Code:
esmart.sh: cannot open pre: No such file or directory																			 
																																 
+------+---------------+----+-----+-----+-----+-------+-------+--------+------+----------+------+-------+						 
|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  |						 
+------+---------------+----+-----+-----+-----+-------+-------+--------+------+----------+------+-------+						 
esmart.sh: 31: Syntax error: ")" unexpected

Any ideas why it's not working on freenas2?

Thanks
 
Last edited by a moderator:

zoomzoom

Guru
Joined
Sep 6, 2015
Messages
677
@AdrianWilliamson I can run the script you posted just fine without the errors, which means there's likely an issue with how you copied and pasted.
  1. Copy script in your previous post
  2. Log into FreeNAS via SSH
  3. Issue: nano esmart.sh
    • if your editing your current script, first issue: echo > esmart.sh
  4. Right click in the terminal
  5. Once all text has populated: CTRL+ X, Y, then ENTER
    • If not editing your original script, issue: chmod +x esmart.sh
/tmp/smart_report.tmp
Code:
To: "freenas2@email.co.uk"
Subject: SMART Status Report for freenas2
Content-Type: text/html
MIME-Version: 1.0


<pre style="font-size:14px">

########## 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  |
+------+---------------+----+-----+-----+-----+-------+-------+--------+------+----------+------+-------+
|ada0  |Z30xxxxx	   | 31 |13015|  136|	0|	  0|	  0|	   0|	 3| 357739695|	 0|	  4|
|ada1  |Z30xxxxx	   | 30 | 6863|24171|	0|	  0|	  0|	   0|	 0|  41963565|	 0|	  6|
|ada2  |WD-WXxxx	   | 34 | 2881|  124|	0|	  0|	  0|	   0|   N/A|	   N/A|   N/A|	N/A|
|ada3  |W4Jxxxxx	   | 34 | 7336|36028|	0|	  0|	  0|	   0|	 2| 351773177|	 0|	  1|
|ada4  |W4Jxxxxx	   | 34 | 7174|37090|	0|	  0|	  0|	   0|	 3| 340287031|	 0|	  1|
+------+---------------+----+-----+-----+-----+-------+-------+--------+------+----------+------+-------+



########## SMART status report for ada0 drive (Seagate Desktop HDD.15: Z30xxxxx) ##########
smartctl 6.5 2016-05-07 r4318 [FreeBSD 11.0-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	 0x000f   118   099   006	Pre-fail  Always	   -	   182861648
  3 Spin_Up_Time			0x0003   092   091   000	Pre-fail  Always	   -	   0
  4 Start_Stop_Count		0x0032   100   100   020	Old_age   Always	   -	   136
  5 Reallocated_Sector_Ct   0x0033   100   100   010	Pre-fail  Always	   -	   0
  7 Seek_Error_Rate		 0x000f   080   060   030	Pre-fail  Always	   -	   13242641583
  9 Power_On_Hours		  0x0032   086   086   000	Old_age   Always	   -	   13015
10 Spin_Retry_Count		0x0013   100   100   097	Pre-fail  Always	   -	   0
12 Power_Cycle_Count	   0x0032   100   100   020	Old_age   Always	   -	   62
183 Runtime_Bad_Block	   0x0032   027   027   000	Old_age   Always	   -	   73
184 End-to-End_Error		0x0032   100   100   099	Old_age   Always	   -	   0
187 Reported_Uncorrect	  0x0032   100   100   000	Old_age   Always	   -	   0
188 Command_Timeout		 0x0032   100   098   000	Old_age   Always	   -	   4 4 10
189 High_Fly_Writes		 0x003a   100   100   000	Old_age   Always	   -	   0
190 Airflow_Temperature_Cel 0x0022   069   047   045	Old_age   Always	   -	   31 (Min/Max 27/43)
191 G-Sense_Error_Rate	  0x0032   100   100   000	Old_age   Always	   -	   0
192 Power-Off_Retract_Count 0x0032   100   100   000	Old_age   Always	   -	   52
193 Load_Cycle_Count		0x0032   096   096   000	Old_age   Always	   -	   9608
194 Temperature_Celsius	 0x0022   031   053   000	Old_age   Always	   -	   31 (0 16 0 0 0)
197 Current_Pending_Sector  0x0012   100   100   000	Old_age   Always	   -	   0
198 Offline_Uncorrectable   0x0010   100   100   000	Old_age   Offline	  -	   0
199 UDMA_CRC_Error_Count	0x003e   200   198   000	Old_age   Always	   -	   69
240 Head_Flying_Hours	   0x0000   100   253   000	Old_age   Offline	  -	   12664h+05m+41.361s
241 Total_LBAs_Written	  0x0000   100   253   000	Old_age   Offline	  -	   148986766239
242 Total_LBAs_Read		 0x0000   100   253   000	Old_age   Offline	  -	   48057613803

No Errors Logged

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



########## SMART status report for ada1 drive (Seagate Desktop HDD.15: Z30xxxxx) ##########
smartctl 6.5 2016-05-07 r4318 [FreeBSD 11.0-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	 0x000f   111   099   006	Pre-fail  Always	   -	   33811368
  3 Spin_Up_Time			0x0003   094   092   000	Pre-fail  Always	   -	   0
  4 Start_Stop_Count		0x0032   077   077   020	Old_age   Always	   -	   24171
  5 Reallocated_Sector_Ct   0x0033   100   100   010	Pre-fail  Always	   -	   0
  7 Seek_Error_Rate		 0x000f   076   060   030	Pre-fail  Always	   -	   41963565
  9 Power_On_Hours		  0x0032   093   093   000	Old_age   Always	   -	   6863
10 Spin_Retry_Count		0x0013   100   100   097	Pre-fail  Always	   -	   0
12 Power_Cycle_Count	   0x0032   100   100   020	Old_age   Always	   -	   76
183 Runtime_Bad_Block	   0x0032   100   100   000	Old_age   Always	   -	   0
184 End-to-End_Error		0x0032   100   100   099	Old_age   Always	   -	   0
187 Reported_Uncorrect	  0x0032   100   100   000	Old_age   Always	   -	   0
188 Command_Timeout		 0x0032   100   097   000	Old_age   Always	   -	   6 6 7
189 High_Fly_Writes		 0x003a   100   100   000	Old_age   Always	   -	   0
190 Airflow_Temperature_Cel 0x0022   070   056   045	Old_age   Always	   -	   30 (Min/Max 26/40)
191 G-Sense_Error_Rate	  0x0032   100   100   000	Old_age   Always	   -	   0
192 Power-Off_Retract_Count 0x0032   100   100   000	Old_age   Always	   -	   11
193 Load_Cycle_Count		0x0032   079   079   000	Old_age   Always	   -	   43495
194 Temperature_Celsius	 0x0022   030   044   000	Old_age   Always	   -	   30 (0 19 0 0 0)
197 Current_Pending_Sector  0x0012   100   100   000	Old_age   Always	   -	   0
198 Offline_Uncorrectable   0x0010   100   100   000	Old_age   Offline	  -	   0
199 UDMA_CRC_Error_Count	0x003e   200   200   000	Old_age   Always	   -	   0
240 Head_Flying_Hours	   0x0000   100   253   000	Old_age   Offline	  -	   6122h+33m+47.780s
241 Total_LBAs_Written	  0x0000   100   253   000	Old_age   Offline	  -	   18980099920
242 Total_LBAs_Read		 0x0000   100   253   000	Old_age   Offline	  -	   10759461925574

No Errors Logged

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



########## SMART status report for ada2 drive (Western Digital Red: WD-WXxxxxx) ##########
smartctl 6.5 2016-05-07 r4318 [FreeBSD 11.0-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   204   200   021	Pre-fail  Always	   -	   8800
  4 Start_Stop_Count		0x0032   100   100   000	Old_age   Always	   -	   124
  5 Reallocated_Sector_Ct   0x0033   200   200   140	Pre-fail  Always	   -	   0
  7 Seek_Error_Rate		 0x002e   100   253   000	Old_age   Always	   -	   0
  9 Power_On_Hours		  0x0032   097   097   000	Old_age   Always	   -	   2881
10 Spin_Retry_Count		0x0032   100   100   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	   -	   75
192 Power-Off_Retract_Count 0x0032   200   200   000	Old_age   Always	   -	   61
193 Load_Cycle_Count		0x0032   200   200   000	Old_age   Always	   -	   2371
194 Temperature_Celsius	 0x0022   118   107   000	Old_age   Always	   -	   34
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   197   000	Old_age   Always	   -	   26
200 Multi_Zone_Error_Rate   0x0008   200   200   000	Old_age   Offline	  -	   0

ATA Error Count: 2
	CR = Command Register [HEX]
	FR = Features Register [HEX]
	SC = Sector Count Register [HEX]
	SN = Sector Number Register [HEX]
	CL = Cylinder Low Register [HEX]
	CH = Cylinder High Register [HEX]
	DH = Device/Head Register [HEX]
	DC = Device Command Register [HEX]
	ER = Error register [HEX]
	ST = Status register [HEX]
Powered_Up_Time is measured from power on, and printed as
DDd+hh:mm:SS.sss where DD=days, hh=hours, mm=minutes,
SS=sec, and sss=millisec. It "wraps" after 49.710 days.

Error 2 occurred at disk power-on lifetime: 403 hours (16 days + 19 hours)
  When the command that caused the error occurred, the device was active or idle.

  After command completion occurred, registers were:
  ER ST SC SN CL CH DH
  -- -- -- -- -- -- --
  40 51 08 28 d5 00 e0  Error: UNC 8 sectors at LBA = 0x0000d528 = 54568

  Commands leading to the command that caused the error were:
  CR FR SC SN CL CH DH DC   Powered_Up_Time  Command/Feature_Name
  -- -- -- -- -- -- -- --  ----------------  --------------------
  c8 00 08 28 d5 00 e0 08   1d+10:18:07.310  READ DMA
  ca 00 08 e8 a1 12 e0 08   1d+10:18:06.830  WRITE DMA
  ca 00 08 c8 fa 11 e0 08   1d+10:18:06.830  WRITE DMA
  ca 00 08 00 f7 11 e0 08   1d+10:18:06.830  WRITE DMA
  ca 00 08 b8 f1 11 e0 08   1d+10:18:06.830  WRITE DMA

Error 1 occurred at disk power-on lifetime: 369 hours (15 days + 9 hours)
  When the command that caused the error occurred, the device was active or idle.

  After command completion occurred, registers were:
  ER ST SC SN CL CH DH
  -- -- -- -- -- -- --
  10 51 08 10 17 35 e0  Error: IDNF at LBA = 0x00351710 = 3479312

  Commands leading to the command that caused the error were:
  CR FR SC SN CL CH DH DC   Powered_Up_Time  Command/Feature_Name
  -- -- -- -- -- -- -- --  ----------------  --------------------
  ca 00 08 10 17 35 e0 08	  03:35:59.609  WRITE DMA
  ca 00 08 60 16 35 e0 08	  03:35:59.609  WRITE DMA
  ca 00 08 20 11 35 e0 08	  03:35:59.607  WRITE DMA
  ca 00 08 08 11 35 e0 08	  03:35:59.607  WRITE DMA
  ca 00 08 b0 10 35 e0 08	  03:35:59.607  WRITE DMA

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



########## SMART status report for ada3 drive (Seagate Desktop HDD.15: W4Jxxxxx) ##########
smartctl 6.5 2016-05-07 r4318 [FreeBSD 11.0-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	 0x000f   115   100   006	Pre-fail  Always	   -	   95570320
  3 Spin_Up_Time			0x0003   092   091   000	Pre-fail  Always	   -	   0
  4 Start_Stop_Count		0x0032   065   065   020	Old_age   Always	   -	   36028
  5 Reallocated_Sector_Ct   0x0033   100   100   010	Pre-fail  Always	   -	   0
  7 Seek_Error_Rate		 0x000f   082   060   030	Pre-fail  Always	   -	   8941707769
  9 Power_On_Hours		  0x0032   092   092   000	Old_age   Always	   -	   7336
10 Spin_Retry_Count		0x0013   100   100   097	Pre-fail  Always	   -	   0
12 Power_Cycle_Count	   0x0032   100   100   020	Old_age   Always	   -	   114
183 Runtime_Bad_Block	   0x0032   100   100   000	Old_age   Always	   -	   0
184 End-to-End_Error		0x0032   100   100   099	Old_age   Always	   -	   0
187 Reported_Uncorrect	  0x0032   100   100   000	Old_age   Always	   -	   0
188 Command_Timeout		 0x0032   100   099   000	Old_age   Always	   -	   1 1 4
189 High_Fly_Writes		 0x003a   100   100   000	Old_age   Always	   -	   0
190 Airflow_Temperature_Cel 0x0022   066   056   045	Old_age   Always	   -	   34 (Min/Max 31/44)
191 G-Sense_Error_Rate	  0x0032   001   001   000	Old_age   Always	   -	   289410
192 Power-Off_Retract_Count 0x0032   100   100   000	Old_age   Always	   -	   23
193 Load_Cycle_Count		0x0032   076   076   000	Old_age   Always	   -	   49825
194 Temperature_Celsius	 0x0022   034   044   000	Old_age   Always	   -	   34 (0 18 0 0 0)
195 Hardware_ECC_Recovered  0x001a   115   100   000	Old_age   Always	   -	   95570320
197 Current_Pending_Sector  0x0012   100   100   000	Old_age   Always	   -	   0
198 Offline_Uncorrectable   0x0010   100   100   000	Old_age   Offline	  -	   0
199 UDMA_CRC_Error_Count	0x003e   200   200   000	Old_age   Always	   -	   0
240 Head_Flying_Hours	   0x0000   100   253   000	Old_age   Offline	  -	   6179h+07m+17.057s
241 Total_LBAs_Written	  0x0000   100   253   000	Old_age   Offline	  -	   29840639131
242 Total_LBAs_Read		 0x0000   100   253   000	Old_age   Offline	  -	   1325184012924

No Errors Logged

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



########## SMART status report for ada4 drive (Seagate Desktop HDD.15: W4Jxxxxx) ##########
smartctl 6.5 2016-05-07 r4318 [FreeBSD 11.0-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	 0x000f   117   100   006	Pre-fail  Always	   -	   161197840
  3 Spin_Up_Time			0x0003   092   091   000	Pre-fail  Always	   -	   0
  4 Start_Stop_Count		0x0032   064   064   020	Old_age   Always	   -	   37090
  5 Reallocated_Sector_Ct   0x0033   100   100   010	Pre-fail  Always	   -	   0
  7 Seek_Error_Rate		 0x000f   080   060   030	Pre-fail  Always	   -	   13225188919
  9 Power_On_Hours		  0x0032   092   092   000	Old_age   Always	   -	   7174
10 Spin_Retry_Count		0x0013   100   100   097	Pre-fail  Always	   -	   0
12 Power_Cycle_Count	   0x0032   100   100   020	Old_age   Always	   -	   103
183 Runtime_Bad_Block	   0x0032   100   100   000	Old_age   Always	   -	   0
184 End-to-End_Error		0x0032   100   100   099	Old_age   Always	   -	   0
187 Reported_Uncorrect	  0x0032   100   100   000	Old_age   Always	   -	   0
188 Command_Timeout		 0x0032   100   080   000	Old_age   Always	   -	   1 1 354
189 High_Fly_Writes		 0x003a   100   100   000	Old_age   Always	   -	   0
190 Airflow_Temperature_Cel 0x0022   066   057   045	Old_age   Always	   -	   34 (Min/Max 30/43)
191 G-Sense_Error_Rate	  0x0032   010   010   000	Old_age   Always	   -	   181921
192 Power-Off_Retract_Count 0x0032   100   100   000	Old_age   Always	   -	   27
193 Load_Cycle_Count		0x0032   079   079   000	Old_age   Always	   -	   43960
194 Temperature_Celsius	 0x0022   034   043   000	Old_age   Always	   -	   34 (0 19 0 0 0)
195 Hardware_ECC_Recovered  0x001a   117   100   000	Old_age   Always	   -	   161197840
197 Current_Pending_Sector  0x0012   100   100   000	Old_age   Always	   -	   0
198 Offline_Uncorrectable   0x0010   100   100   000	Old_age   Offline	  -	   0
199 UDMA_CRC_Error_Count	0x003e   200   200   000	Old_age   Always	   -	   0
240 Head_Flying_Hours	   0x0000   100   253   000	Old_age   Offline	  -	   6240h+54m+02.506s
241 Total_LBAs_Written	  0x0000   100   253   000	Old_age   Offline	  -	   28462867715
242 Total_LBAs_Read		 0x0000   100   253   000	Old_age   Offline	  -	   977524641350

No Errors Logged

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


</pre>

  • Output for Spin_Retry_Count & Power_Cycle_Count are missing a whitespace after their attribute names
 
Last edited:

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504

zoomzoom

Guru
Joined
Sep 6, 2015
Messages
677
Either/or =]
 

adrianwi

Guru
Joined
Oct 15, 2013
Messages
1,231
Thanks for confirming the script was good! I'd kind of guessed it was, as it was working perfectly on freenas1, but couldn't for the life of me work out what was wrong on freenas2. To be honest, I still don't really know! I deleted the old file, created a new one and pasted in the script. And it worked!
 

ArgaWoW

Patron
Joined
Jul 4, 2015
Messages
444
Hello,
I tried this script today for the first time and it looks great. I have just two little issues :) :
- I get some funny letter behind the Temperatur
- I don't get the config-backup as e-mail attachmend, it looks like a Textfile..... a very long Textfile

see the pictures attached pls.
 

Attachments

  • Unbenannt2.jpg
    Unbenannt2.jpg
    105.7 KB · Views: 647
  • Unbenannt.jpg
    Unbenannt.jpg
    150.3 KB · Views: 358

Stux

MVP
Joined
Jun 2, 2016
Messages
4,419

zoomzoom

Guru
Joined
Sep 6, 2015
Messages
677
@ArgaWoW Just an FYI, that text is the RAW output of the tar, and if you copy and paste all the text into a text editor, then add the *.tar extension to it, you can access it. @Stux's previous post with a modified script is the one I use and prefer since the physical attachment is shown, not the RAW code for the attachment

The odd character could be due to english <-> german, however if not, are you using the script without any modifications to the code? If not, please post the script
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
I really need to update my scripts... and I really need more free time...

Regarding the weird letter it's probably due to the ° char, try to replace it with a space for example to see if it's that or something else ;)
 

LotLits

Dabbler
Joined
Apr 10, 2015
Messages
30
That's definitely the issue. I had the same issue. I would replace it with * in the code, which is close enough.
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Ok so it's just an encoding issue, not a big deal then ;)
 
Joined
Jan 4, 2014
Messages
1,644
Brilliant! A big Thank You. Just one question. I note from your schedule that your boot scrub is scheduled for day 1 and 16. How have you managed that? I understand you can set an automatic scrub interval (default 35 days) , but I didn't think that specifying specific days was possible.
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
I've added a task (see the picture below) and I've set the scrub interval to something like 14 days instead of 35 to be sure it won't interfere with the task ;)

scrubtask.png


NB: I'm still on FreeNAS 9.3.0 so it might be different if you use another version.
 

zoomzoom

Guru
Joined
Sep 6, 2015
Messages
677
@Seymour Butt You'll need to select the right hand tab when you're in the scrub schedule dialogue box... see screenshots
 

Attachments

  • Screenshot1.png
    Screenshot1.png
    21.6 KB · Views: 332
  • Screenshot2.png
    Screenshot2.png
    29.6 KB · Views: 368

Xyrgh

Explorer
Joined
Apr 11, 2016
Messages
69
Brilliant! A big Thank You. Just one question. I note from your schedule that your boot scrub is scheduled for day 1 and 16. How have you managed that? I understand you can set an automatic scrub interval (default 35 days) , but I didn't think that specifying specific days was possible.

You can't actually add a scrub for the boot pool as per @Bidule0hm's instructions in FreeNAS9.10, as it doesn't allow you to select the boot pool. What I did was SSH into my box and edited /etc/crontab. You'll see there is already the boot scrub setup, plus your other scrubs. I amended the boot scrub to be in line with the rest of my scrubs.

The only part I don't understand is the '-t 15' in the command, but I assume this is related to my scrub interval of 15 days, I'm struggling to find any documentation on the scrub command that has the '-t' switch. My crontab line looks like:

00 05 01,16 * * root /usr/local/libexec/nas/scrub -t 15 freenas-boot

There is no guarantee that this will survive an update though, I'm going to assume it won't. I wish they'd just allow us to have finer controls around scheduling the boot scrub.

Ignore me, better answers below and above.
 
Last edited:

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
You can't actually add a scrub for the boot pool as per @Bidule0hm's instructions in FreeNAS9.10,
Sure you can. He left out that the task he created is a cron task. You can set up arbitrary cron jobs through the web GUI.
 

Xyrgh

Explorer
Joined
Apr 11, 2016
Messages
69
Sure you can. He left out that the task he created is a cron task. You can set up arbitrary cron jobs through the web GUI.

Sorry, completely missed that he was doing it as a generic cron job and not a scrub job. How does this interact with the scrub schedule in the boot tab? I assume that if you're manually doing scrub via cron on the 1st and 16th, have your interval set to 35 days, that the system won't try to do the regular boot scrub as it can see that is already scrubbed within the last 35 days?
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
Right, the system scrub task will never run, as it will never be 35 days since the last scrub.
 
Top