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
You missed the point
I'm not sure what point you're speaking to. I had originally asked
  • "Couldn't the scripts' directory simply be added to PATH, at which point one could simply invoke <script-name>.sh?"
to which you replied
  • "Where would you edit the path? Most of the files that might be edited by hand in a regular BSD installation to make a configuration change are recreated during the boot of the FreeNAS..."
The path would be specified in the user's ~/.cshrc, of which is never recreated during boot, only ever being replaced when one updates their FreeNAS box (likely once a month at most). Perhaps I'm missing the point you're referencing, as my previous post covered exactly how to accomplish what you had questioned as not possible.
 

ovizii

Patron
Joined
Jun 30, 2014
Messages
435
Since @melp / edgarsuit updated the script, and I unfortunately had some (too much) time in front of my FreeNAS box due to an annoying disk issue I spent some of that time merging my old hacks with the new 1.3 version and added a little extra and put it here https://github.com/fohlsso2/FreeNAS-Report ,

Most of the changes is to make the script better parse all different variants of scan status, and give some info if a scrub or resilver is in progress.
(usual disclaimer here, it works on my box :) )
I have to say, version 1.3 worked for me but with your version the scrub age check seems broken.

Original 1.3
upload_2018-6-21_10-6-27.png


Your fixed version:
upload_2018-6-21_10-7-9.png


Other than that the report looks fine. Weirdly enough, if I scroll down to the details of my pools, the scrub information is there:
upload_2018-6-21_10-8-44.png
 

Sjöhaga

Dabbler
Joined
Apr 17, 2016
Messages
41
I have to say, version 1.3 worked for me but with your version the scrub age check seems broken.

darn,
but I see what I did :(

Seriously, I must have been really tired at the end yesterday, I even documented the same errors in my pictures :P , geez.
 

ovizii

Patron
Joined
Jun 30, 2014
Messages
435
darn,
but I see what I did :(

Seriously, I must have been really tired at the end yesterday, I even documented the same errors in my pictures :p , geez.
No worries and thanks for the script. Btw. I couldn't see the pictures, tried several times but imgur kept telling me they're experiencing high load and was showing me only placeholders for your images.
 

Sjöhaga

Dabbler
Joined
Apr 17, 2016
Messages
41
This is how it is supposed to look:
CUNUZ7r.png


And not like this :) :
YGmvZT4.png
 

Sjöhaga

Dabbler
Joined
Apr 17, 2016
Messages
41
and commited a fix. Should work better now :)

2018-06-21_16-59-33.png
 

diskdiddler

Wizard
Joined
Jul 9, 2014
Messages
2,377
Are any of the scripts and work in this thread moving into freenas official?

Just curious.
 

wintecaa

Cadet
Joined
Jun 26, 2018
Messages
3
Hi I am new to this, am not able to make the script working.
Can someone help checking ?

Im using FreeNAS-9.3-STABLE-201509282017


[root@freenas1] ~# ./smart_report.sh
[root@freenas1] ~#


Code:
[root@freenas1] ~# cat -e smart_report.sh
#!/bin/sh$
$
### Parameters ###$
logfile="/tmp/smart_report.tmp"$
email="xxxxx@gmail.com"$
subject="SMART Status Report"$
drives="da0 da1 da2 da3 da4 da5 da6 da7"$
tempWarn=40$
tempCrit=45$
sectorsCrit=10$
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 |Seek  |Total	 |High  |Command|"$
	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$
	($
		smartctl -A -i -v 7,hex48 /dev/${drive} | \$
		awk -v device=${drive} -v tempWarn=${tempWarn} -v tempCrit=${tempCrit} -v sectorsCrit=${sectorsCrit} \$
		-v warnSymbol=${warnSymbol} -v critSymbol=${critSymbol} '\$
		/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 {$
			if (temp > tempCrit || reAlloc > sectorsCrit || pending > sectorsCrit || offlineUnc > sectorsCrit)$
				device=device " " critSymbol;$
			else if (temp > tempWarn || reAlloc > 0 || pending > 0 || offlineUnc > 0)$
				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|%-18s| %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}'`$
	if [ -z "$brand" ];$
	then$
	  brand=`smartctl -i /dev/${drive} | grep "Device Model" | awk '{print $3, $4, $5}'`$
	fi$
	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}$
 

Sjöhaga

Dabbler
Joined
Apr 17, 2016
Messages
41

wintecaa

Cadet
Joined
Jun 26, 2018
Messages
3
I am using smart_report from spearfoot's repo over here : https://github.com/Spearfoot/FreeNAS-scripts , but your script doesn't look like his.
However, since you don't tell us what kind of error you get it is a little difficult to help ;)

@SJ Thanks replaying. The problem is it does not have any output (error), but it works on some of the scripts.

Example: get_hdd_temp.sh
Code:
[root@freenas1] ~# ./get_hdd_temp.sh
=== CPU (16) ===
CPU  0:   27C
CPU  1:   27C
CPU  2:   30C
CPU  3:   31C
CPU  4:   31C
CPU  5:   31C
CPU  6:   32C
CPU  7:   32C
CPU  8:   35C
CPU  9:   35C
CPU 10:   35C
CPU 11:   35C
CPU 12:   34C
CPU 13:   34C
CPU 14:   36C
CPU 15:   35C

=== DRIVES ===
   da0:   35C [4.00TB] PN2334PBJ568HT	   Hitachi/HGST Ultrastar 7K4000 (HGST HUS724040ALA640)
   da1:   36C [4.00TB] PN2334PBJ4R36T	   Hitachi/HGST Ultrastar 7K4000 (HGST HUS724040ALA640)
   da2:   37C [4.00TB] PN2334PBJ509ZT	   Hitachi/HGST Ultrastar 7K4000 (HGST HUS724040ALA640)
   da3:   35C [4.00TB] PN2334PBJ4SHVT	   Hitachi/HGST Ultrastar 7K4000 (HGST HUS724040ALA640)
   da4:   38C [4.00TB] PN2334PBJ346XT	   Hitachi/HGST Ultrastar 7K4000 (HGST HUS724040ALA640)
   da5:   38C [4.00TB] PN2334PBJ4R33T	   Hitachi/HGST Ultrastar 7K4000 (HGST HUS724040ALA640)
   da6:   37C [4.00TB] PN2334PBJ4R3JT	   Hitachi/HGST Ultrastar 7K4000 (HGST HUS724040ALA640)
   da7:   38C [4.00TB] PK2331PAGBPYGW	   Hitachi/HGST Ultrastar 7K4000 (HGST HUS724040ALE640)
   da8:   39C [4.00TB] WD-WMC130D138TS	  Western Digital Re (WDC WD4000FYYZ-01UL1B2)
   da9:   39C [4.00TB] WD-WMC130D79AFZ	  Western Digital Re (WDC WD4000FYYZ-01UL1B2)
  da11:   39C [4.00TB] WD-WCC130835751	  Western Digital Re (WDC WD4000FYYZ-01UL1B1)
  da12:   35C [4.00TB] WD-WMC130D7U6YH	  Western Digital Re (WDC WD4000FYYZ-01UL1B2)
  da13:   36C [4.00TB] WD-WCC130855521	  Western Digital Re (WDC WD4000FYYZ-01UL1B1)
  da14:   37C [4.00TB] WD-WCC130870094	  Western Digital Re (WDC WD4000FYYZ-01UL1B1)
  da15:   38C [4.00TB] WD-WCC5D0074441	  Western Digital Se (WDC WD4000F9YZ-09N20L0)
  da16:   38C [4.00TB] PN2334PBJ4SSST	   Hitachi/HGST Ultrastar 7K4000 (HGST HUS724040ALA640)
  da17:   36C [4.00TB] WD-WCC132129836	  Western Digital Se (WDC WD4000F9YZ-09N20L0)
  da10:   37C [4.00TB] PN1334PEHXRXXS	   Hitachi/HGST Ultrastar 7K4000 (HGST HUS724040ALA640)
  ada0:   30C [2.00TB] WD-WMAY04549093	  Western Digital RE4 (WDC WD2003FYYS-02W0B1)
  ada1:   26C [3.00TB] PN1234P9G2WNVP	   Hitachi/HGST Ultrastar 7K4000 (HGST HUS724030ALA640)
  ada2:   30C [2.00TB] WD-WMAY04457976	  Western Digital RE4 (WDC WD2003FYYS-02W0B1)
  ada3:   32C [2.00TB] WD-WMAY02706800	  Western Digital RE4 (WDC WD2003FYYS-02W0B0)
  ada4:   23C [120GB]  PHWL516601WS120LGN   Intel 730 and DC S35x0/3610/3700 (INTEL SSDSC2BB120G4)
  ada5:   23C [120GB]  PHWL516601W7120LGN   Intel 730 and DC S35x0/3610/3700 (INTEL SSDSC2BB120G4)


I copied and pasted it as smart_report1.sh, first it returns no email found, after I added the address and rerun the script, it returns nothing.

[root@freenas1] ~# ./smart_report1.sh
No email address specified, information available in /tmp/smart_report.tmp

[root@freenas1] ~# ./smart_report1.sh
[root@freenas1] ~#


Code:
[root@freenas1] ~# cat -e smart_report1.sh
#!/bin/sh$
$
### Parameters ###$
$
# Specify your email address here:$
email="wintecaa@gmail.com"$
$
freenashost=$(hostname -s | tr '[:lower:]' '[:upper:]')$
smartctl=/usr/local/sbin/smartctl$
logfile="/tmp/smart_report.tmp"$
subject="SMART Status Report for ${freenashost}"$
tempWarn=40$
tempCrit=45$
sectorsCrit=10$
testAgeWarn=1$
warnSymbol="?"$
critSymbol="!"$
$
# We need a list of the SMART-enabled drives on the system. Choose one of these$
# three methods to provide the list. Comment out the two unused sections of code.$
$
# 1. A string constant; just key in the devices you want to report on here:$
#drives="da1 da2 da3 da4 da5 da6 da7 da8 ada0"$
$
# 2. A systcl-based technique suggested on the FreeNAS forum:$
#drives=$(for drive in $(sysctl -n kern.disks); do \$
#if [ "$("${smartctl}" -i /dev/${drive} | grep "SMART support is: Enabled" | awk '{print $3}')" ]$
#then printf ${drive}" "; fi done | awk '{for (i=NF; i!=0 ; i--) print $i }')$
$
# 3. A smartctl-based function:$
get_smart_drives()$
{$
  gs_drives=$("${smartctl}" --scan | grep "dev" | awk '{print $1}' | sed -e 's/\/dev\///' | tr '\n' ' ')$
$
  gs_smartdrives=""$
$
  for gs_drive in $gs_drives; do$
	gs_smart_flag=$("${smartctl}" -i /dev/"$gs_drive" | grep "SMART support is: Enabled" | awk '{print $4}')$
	if [ "$gs_smart_flag" = "Enabled" ]; then$
	  gs_smartdrives=$gs_smartdrives" "${gs_drive}$
	fi$
  done$
$
  eval "$1=\$gs_smartdrives"$
}$
$
drives=""$
get_smart_drives drives$
$
# end of method 3.$
$
### Set email headers ###$
($
  echo "To: ${email}"$
  echo "Subject: ${subject}"$
  echo "Content-Type: text/html"$
  echo "MIME-Version: 1.0"$
  printf "\r\n"$
) > ${logfile}$
$
### Set email body ###$
echo "<pre style=\"font-size:14px\">" >> ${logfile}$
$
###### summary ######$
($
 echo "########## SMART status report summary for all drives on server ${freenashost} ##########"$
 echo ""$
 echo "+------+------------------+----+-----+-----+-----+-------+-------+--------+------+----------+------+-------+----+"$
 echo "|Device|Serial			|Temp|Power|Start|Spin |ReAlloc|Current|Offline |Seek  |Total	 |High  |Command|Last|"$
 echo "|	  |Number			|	|On   |Stop |Retry|Sectors|Pending|Uncorrec|Errors|Seeks	 |Fly   |Timeout|Test|"$
 echo "|	  |				  |	|Hours|Count|Count|	   |Sectors|Sectors |	  |		  |Writes|Count  |Age |"$
 echo "+------+------------------+----+-----+-----+-----+-------+-------+--------+------+----------+------+-------+----+"$
) >> ${logfile}$
$
for drive in $drives; do$
  ($
  lastTestHours=$("${smartctl}" -l selftest /dev/"${drive}" | grep "# 1" | awk '{print $9}')$
  "${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="${lastTestHours}" '$
  /Serial Number:/{serial=$3}$
  /190 Airflow_Temperature/{temp=$10}$
  /194 Temperature/{temp=$10}$
  /Power_On_Hours/{split($10,a,"+");sub(/h/,"",a[1]);onHours=a[1];}$
  /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 {$
	  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|%-18s| %s |%5s|%5s|%5s|%7s|%7s|%8s|%6s|%10s|%6s|%7s|%4s|\n",$
	  device, serial, temp, onHours, startStop, spinRetry, reAlloc, pending, offlineUnc,$
	  seekErrors, totalSeeks, hiFlyWr, cmdTimeout, testAge;$
	  }'$
  ) >> ${logfile}$
done$
$
($
  echo "+------+------------------+----+-----+-----+-----+-------+-------+--------+------+----------+------+-------+----+"$
) >> ${logfile}$
$
###### for each drive ######$
for drive in $drives; do$
  brand=$("${smartctl}" -i /dev/"${drive}" | grep "Model Family" | awk '{print $3, $4, $5}')$
  if [ -z "$brand" ]; then$
	brand=$("${smartctl}" -i /dev/"${drive}" | grep "Device Model" | awk '{print $3, $4, $5}')$
  fi$
  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-$
  ) >> ${logfile}$
done$
$
sed -i '' -e '/smartctl 6.*/d' ${logfile}$
sed -i '' -e '/smartctl 5.*/d' ${logfile}$
sed -i '' -e '/smartctl 4.*/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 ###$
if [ -z "${email}" ]; then$
  echo "No email address specified, information available in ${logfile}"$
else$
#  sendmail -t < ${logfile}$
  sendmail ${email} < ${logfile}$
  rm ${logfile}$
fi$
 

Sjöhaga

Dabbler
Joined
Apr 17, 2016
Messages
41
@SJ Thanks replaying. The problem is it does not have any output (error), but it works on some of the scripts.

I copied and pasted it as smart_report1.sh, first it returns no email found, after I added the address and rerun the script, it returns nothing.

[root@freenas1] ~# ./smart_report1.sh
No email address specified, information available in /tmp/smart_report.tmp

[root@freenas1] ~# ./smart_report1.sh
[root@freenas1] ~#

Well, if it doesn't complain I'd say it is working, you should get an email after a few seconds with the collected information. At least if your email-setup in FreeNAS is working as it should.
Do you get the ordinary emails from your FreeNAS box?

In spearfoots repo the three scripts that has report in the name all sends their info using email, the two temperature scripts show the info in the terminal if you run them there though.
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
I copied and pasted it as smart_report1.sh, first it returns no email found, after I added the address and rerun the script, it returns nothing.

[root@freenas1] ~# ./smart_report1.sh
No email address specified, information available in /tmp/smart_report.tmp

[root@freenas1] ~# ./smart_report1.sh
[root@freenas1] ~#
Have you configured the email settings on your FreeNAS system? These are the settings under the System->Email tab, where you specify your mail server, port, TLS/SSL, SMTP authentication, username, password, etc.
 

diedrichg

Wizard
Joined
Dec 4, 2012
Messages
1,319
@SJ Thanks replaying. The problem is it does not have any output (error), but it works on some of the scripts.
There were some underlying changes in FN11.1 that broke the old script, some minor changes needed to be made to the script. This may be what is affecting your 9.x scripts. The OP is probably updated to work with 11.1?
 

wintecaa

Cadet
Joined
Jun 26, 2018
Messages
3
Have you configured the email settings on your FreeNAS system? These are the settings under the System->Email tab, where you specify your mail server, port, TLS/SSL, SMTP authentication, username, password, etc.

I guess my freenas box is a bit weird, i dont see root user under accounts, or it was hidden by default.
Back to the script question, so the script wont work until the email setting is configured?

upload_2018-6-26_15-31-39.png


upload_2018-6-26_15-34-49.png
 

Attachments

  • upload_2018-6-26_15-31-2.png
    upload_2018-6-26_15-31-2.png
    33.6 KB · Views: 456
Last edited:

Sjöhaga

Dabbler
Joined
Apr 17, 2016
Messages
41

svtkobra7

Patron
Joined
Jan 12, 2017
Messages
202
@Bidule0hm This is a nice collection of scripts. Thanks for making available! :)

Is there any way to easily (don't want to waste anyone's time) achieve the following?
  • pull serial numbers for nvme devices, i.e. smartctl -i /dev/nvme2
  • integrate enclosure from sas2ircu 0 display, i.e. join by serial
  • where no gptid exists from glabel status -s, simply don't present the "No such geom" notation? Note the reason for those devices not returning a gptid is because they aren't part of any pool at the moment; however, depending if nvd0 / nvme0 can be joined to produce output relevant to nvme devices, it may still be relevant.
Thanks in advance.

As you can see from below, I added temperature to the script (relevant for me, I know there are separate scripts that achieve same), but beyond simple edits such as that, the above are a bit beyond my skill set at the moment.

Code:
+========+============================================+====================+======+
| Device | GPTID									  | Serial			 | Temp |
+========+============================================+====================+======+
glabel: No such geom: da0p1.
| da0	|											| 12345678		   | 38   |
+--------+--------------------------------------------+--------------------+------+

[da1 - da15 + nvd3/nvme3 output removed for brevity]

+--------+--------------------------------------------+--------------------+------+
| da16   | gptid/7543fefa-7d10-11e8-ae06-000c2999bfe2 | 12345678		   |	  |
+--------+--------------------------------------------+--------------------+------+
| nvd0   | gptid/3a3a6557-7c05-11e8-ab95-000c2999bfe2 |					|	  |
+--------+--------------------------------------------+--------------------+------+
glabel: No such geom: nvd1p1.
| nvd1   |											|					|	  |
+--------+--------------------------------------------+--------------------+------+
| nvd2   | gptid/98224401-7f22-11e8-96ae-000c2999bfe2 |					|	  |
+--------+--------------------------------------------+--------------------+------+
glabel: No such geom: nvme0p1.
| nvme0  |											| VMware			 |	  |
+--------+--------------------------------------------+--------------------+------+
glabel: No such geom: nvme1p1.
| nvme1  |											| 12345678		   |	  |
+--------+--------------------------------------------+--------------------+------+
glabel: No such geom: nvme2p1.
| nvme2  |											| VMware			 |	  |
+--------+--------------------------------------------+--------------------+------+

[note 1 "12345678"substituted for actual serial numbers / blanks = as is from script output
[note 2 VMware serial = virtual disk]


Note: I wanted to include each nvme device separately (defined drives) as nvd0 and nvme0 duplicatively (sic) to illustrate that:
  • glabel status -s nvd0p1 = gptid needed
  • smartctl -i /dev/nvme1 = serial needed
Edits to Original Script
Code:
#!/bin/sh
drives="da0 da1 da2 da3 da4 da5 da6 da7 da8 da9 da10 da11 da12 da13 da14 da15 da16 nvd0 nvd1 nvd2 nvd3 nvme0 nvme1 nvme2 nvme3"
echo ""
echo "+========+============================================+====================+======+"
echo "| Device | GPTID									  | Serial			 | Temp |"
echo "+========+============================================+====================+======+"
for drive in $drives
do
	gptid=`glabel status -s "${drive}p1" | awk '{print $1}'`
	serial=`smartctl -i /dev/${drive} | grep "Serial Number" | awk '{print $3}'`
   temp=`smartctl -A /dev/${drive} | grep "194 Temperature" | awk '{print $10}'`
	printf "| %-6s | %-42s | %-18s | %-5s| \n" "$drive" "$gptid" "$serial" "$temp"
	echo "+--------+--------------------------------------------+--------------------+------+"
done
echo ""

sas2ircu 0 display (excerpt)
Note: If possible to join by serial, I believe that would be helpful to more individuals than myself as enclosure 2 = R2C1 on my SMCI 836.

Code:
Device is a Hard disk
	Enclosure #							 : 2
	Slot #								  : 0
	SAS Address							 : 5003048-0-0010-aaac
	State								   : Ready (RDY)
	Size (in MB)/(in sectors)			   : 5723166/11721045167
	Manufacturer							: ATA
	Model Number							: HGST HDN726060AL
	Firmware Revision					   : T517
	Serial No							   : 12345678
	GUID									: N/A
	Protocol								: SATA
	Drive Type							  : SATA_HDD
 

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080
I guess my freenas box is a bit weird, i don't see root user under accounts, or it was hidden by default.
It should be there. If not, something is wrong with your system.

upload_2018-7-4_17-40-34.png
 

adrianwi

Guru
Joined
Oct 15, 2013
Messages
1,231
I've gone back a few pages, but can't seem to find a similar issue. I recently upgraded from 9.10.1-U4 on my backup box to 11.1-U5 and all went well, but my scripts didn't run when scheduled today.

Agh, I'd forgotten to copy them back to /etc so I did this and ran manually. The SMART one worked fine, but the zpool one didn't so when I tried to run in the CLI I get this error:

Code:
[root@freenas2 /etc]# sh ./ezpool.sh										   
Failed conversion of ``17-on-Tue_Jul'' using format ``%Y-%b-%e_%H:%M:%S''	   
date: illegal time format													   
usage: date [-jnRu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...   
		   [-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format]			   
./ezpool.sh: arithmetic expression: expecting primary: "((1532004600 - ) + 43200
) / 86400"


I thought I'd download a newer script from the OP, but trying this with the variables updated doesn't work either!

Code:
[root@freenas2 /etc]# sh ./ezpool2.sh										   
: not foundh:																   
: not foundh:																   
: not foundh:																   
: not foundh:																   
: not foundh:																   
: not foundh:																   
./ezpool2.sh: 37: Syntax error: word unexpected 


Which are the best to download, and shouldn't these be part of FreeNAS by now?
 

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080

dyobetem

Cadet
Joined
Aug 6, 2018
Messages
3
is there a script that can send to email when the scrub and smart test started and finished and email the result after the scrubbing and smart test? it seems I am not receiving any emails when scrub and smart test run and finish...

thanks!

edit: i create a cron job to start the scrubbing of my pool and after that i received an email that scrubbing is finished.

is there a script that can send an email when the scrubbing starts?
 
Last edited:
Top