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

Byggare

Dabbler
Joined
Jul 14, 2018
Messages
10
Hey guys, im getting these errors using the ZFSPOOL script

Code:
Failed conversion of ``6-on-Tue_Nov'' 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]
Failed conversion of ``7-on-Sun_Oct'' 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]
Failed conversion of ``7-on-Sun_Oct'' 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]


upload_2018-11-10_15-12-43.png

Any clues? I am using 24h format if that makes a difference
 
Last edited by a moderator:

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080
Hey guys, im getting these errors using the ZFSPOOL script

Code:
Failed conversion of ``6-on-Tue_Nov'' 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]
Failed conversion of ``7-on-Sun_Oct'' 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]
Failed conversion of ``7-on-Sun_Oct'' 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]


View attachment 26523
Any clues? I am using 24h format if that makes a difference
What version of the script are you running and what version of FreeNAS. It matters.
 

Chris Moore

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

FreeNAS-11.1-U6
Did you recently upgrade from a previous version of FreeNAS? Did you recently implement the use of this script? You need to give some explanation of the circumstances or nobody will be able to help you
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
Hey guys, im getting these errors using the ZFSPOOL script

Code:
Failed conversion of ``6-on-Tue_Nov'' 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]
Failed conversion of ``7-on-Sun_Oct'' 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]
Failed conversion of ``7-on-Sun_Oct'' 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]


View attachment 26523
Any clues? I am using 24h format if that makes a difference
What version of the zpool_report.sh script are you running? Where did you get it?

@Chris Moore and I fixed (my version of) the zpool_report.sh script to handle the slightly different date formats returned by the zpool command between FreeNAS versions 11.0 and 11.1 about a year ago, and this may be the source of your problem.

The fix is available on GitHub via my resource here on the site:

https://forums.freenas.org/index.ph...for-freenas-scripts-including-disk-burnin.28/
 

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080
Exactly as @Spearfoot said. I first saw this around December of 2017 in this thread
https://forums.freenas.org/index.php?threads/scripts-to-report-smart-zpool-and-ups-status-hdd-cpu-t°-hdd-identification-and-backup-the-config.27365/page-33#post-424216
It was also discussed here:
https://forums.freenas.org/index.ph...ncluding-disk-burnin.52297/page-3#post-424153

It was caused by a difference in format in the output of zpool status, which is where the data comes from that is reported in this script output.
 

Byggare

Dabbler
Joined
Jul 14, 2018
Messages
10
What version of the zpool_report.sh script are you running? Where did you get it?

@Chris Moore and I fixed (my version of) the zpool_report.sh script to handle the slightly different date formats returned by the zpool command between FreeNAS versions 11.0 and 11.1 about a year ago, and this may be the source of your problem.

The fix is available on GitHub via my resource here on the site:

https://forums.freenas.org/index.ph...for-freenas-scripts-including-disk-burnin.28/


Thanks Spearfoot this was indeed the issue, i tried using the last ones but these also throw me errors
"./ZPOOL_Script.sh: 33: Syntax error: word unexpected"

Appreciate the help!
 

diskdiddler

Wizard
Joined
Jul 9, 2014
Messages
2,377
Can someone please confirm for me, the TLER set erc command, how to enable this to START with FreeNAS.
Furthermore, I am shucking drives, I may get a mix of red and white, does it matter if I set it on both disks, despite the red already being enabled?
Finally, will it stuff up my 2 SSDs?
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Can we please keep thread on-topic, it's already long enough, thanks ;)
 

ere109

Contributor
Joined
Aug 22, 2017
Messages
190
I adjusted and installed the HD/Temp script, tonight, on 11.1-U6. I created a scripts folder in the root directory and ran chmod after making the file. However, I got errors.

My script:
Code:
#!/bin/sh

### Parameters ###
cores=16
drives="da0 da1 da2 da3 da4 da5 ada0 ada1"

### CPU ###
echo ""
cores=$((cores - 1))
for core in $(seq 0 $cores)
do
	temp="$(sysctl -a | grep "cpu.${core}.temp" | cut -c24-25 | tr -d "\n")"
	printf "CPU %s: %s C\n" "$core" "$temp"
done

### Disks ###
echo ""
for drive in $drives
do
	serial="$(smartctl -i /dev/${drive} | grep "Serial Number" | awk '{print $3}')"
	temp="$(smartctl -A /dev/${drive} | grep "Temperature_Celsius" | awk '{print $10}')"
	printf "%s %-15s: %s C\n" "$drive" "$serial" "$temp"
done
echo ""


The returned output:
Code:
[root@FreeNAS /scripts]# ./cpu_hd.sh											
 cores=15 for core in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 do			  
usage: tr [-Ccsu] string1 string2											  
	  tr [-Ccu] -d string1													
	  tr [-Ccu] -s string1													
	  tr [-Ccu] -ds string1 string2											
./cpu_hd.sh: \n: not found													
CPU :  C																		
CPU done:  C																	
 for drive in da0 da1 da2 da3 da4 da5 ada0 ada1 do							
usage: awk [-F fs] [-v var=value] [-f progfile | 'prog'] [file ...]			
./cpu_hd.sh: {print $3}: not found											
usage: awk [-F fs] [-v var=value] [-f progfile | 'prog'] [file ...]			
./cpu_hd.sh: {print $10}: not found											
			   :  C															
done				:  C


What did I miss or do wrong?
NOTE: I'm running SATA drives on a SAS controller, and used the SATA script.
 

bkvamme

Dabbler
Joined
Jun 26, 2014
Messages
16
Hi,
Modified the drive info script to fit my server. Now allows for single partition drives (without swap/spacing), nvme drives and also shows model number and capacity, plus some blank columns for writing in bay, slot and when it was purchased.

Script:
https://raw.githubusercontent.com/bkvamme/freenas-scripts/master/driveinfo.sh

Output:
https://raw.githubusercontent.com/bkvamme/freenas-scripts/master/driveinfo.sh-output

Might be spinning this into a csv file aswell to be able to work easier with it in a spreadsheet. Hope someone might find it useful!

edit: And done. CSV version is now available. Works in Excel at least, should work in Google Sheets etc aswell.

CSV script:
https://raw.githubusercontent.com/bkvamme/freenas-scripts/master/driveinfo_csv.sh
Output:
https://raw.githubusercontent.com/bkvamme/freenas-scripts/master/driveinfo_csv.sh-output
 
Last edited:

bsodmike

Dabbler
Joined
Sep 5, 2017
Messages
22
I was able to fix the script by making these changes -

Code:
scrubDate="$(zpool status "$pool" | grep "scan" | awk '{print $17"-"$14"-"$15"_"$16}')"
 

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080
I was able to fix the script by making these changes -

Code:
scrubDate="$(zpool status "$pool" | grep "scan" | awk '{print $17"-"$14"-"$15"_"$16}')"
That was fixed a couple years ago, look here:
https://www.ixsystems.com/community/threads/scripts-to-report-smart-zpool-and-ups-status-hdd-cpu-t°-hdd-identification-and-backup-the-config.27365/post-424270

You must have had an old version. The repository is updated:

GitHub repository for FreeNAS scripts, including disk burnin
https://www.ixsystems.com/community...for-freenas-scripts-including-disk-burnin.28/
 

MrTVirus

Dabbler
Joined
Dec 18, 2018
Messages
10
Sorry to necro such a long thread, has anyone been experiencing issues with the send config to email script? Mine appears to just be sending me garbage letting, as if it isn't attaching the file, but sending the file contents via email.

Anyone experience this yet? I am on FreeNAS-11.2-U5 (Build Date: Jun 24, 2019 18:41)


It looks like this in the email, but much much longer:

Code:
begin 644 FreeNAS_Config_2019-08-01_16-14-15.tar
M+B]&<F5E3D%37T-O;F9I9U\R,#$Y+3`X+3`Q7S$V+3$T+3$U+F1B````````
M````````````````````````````````````````````````````````````
M`````````````#`P,#8T,"``,#`P,#`P(``P,#`P,#`@`#`P,#`Q-30T,#`P
M(#$S-3(P-C0T,#(W(#`Q-C0R-0`@,```````````````````````````````
M````````````````````````````````````````````````````````````
M``````````````````````````````````````````!U<W1A<@`P,')O;W0`
M````````````````````````````````````=VAE96P`````````````````
M```````````````````P,#`P,#`@`#`P,#`P,"``````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M``````````````````````!344QI=&4@9F]R;6%T(#,`!``!`0!`("```&O(
M```!L@```;`````'```+LP````0```````````````$`````````````````
M````````````````````````````:\@`+B"8!0,5`$X")0H```&<`_L#]@/Q
M`^P#YP.-`L(#/0-'`YP#B`.#`VH#;P,I`TP#0@,D`Q\##P,)`OT"]P+E`M,"
M\0+'`KL"M0*O`MD#,0*I`J,"G0*7`H4"?P*+`UX#VP/)`NL"<P)M`F<#5`);
M`E4#?0-W`I$#PP)/`DD#-P)#`QD"/0+-`C<"*P.]`F$"WP.Q`P,#9`//`C$"
M)0.W`]4#E@.K`Z4">0/A`A\"&0(3````````````````````````````````
 

zoomzoom

Guru
Joined
Sep 6, 2015
Messages
677
@MrTVirus It's the text output of a tar file. Different email services handle a tar file attachment differently, depending on the HTML encoding of the script being utilized.
  • For example, if I view the email with the tar attachment in Gmail, it will show as an attachment, but if I view the email in Outlook (the program, not email service), it will only show the text output of the tar attachment, but not that actual attached tar file.

If you copy all of the text (starting at the M+ below begin 644 FreeNAS_Config_2019-08-01_16-14-15.tar), paste it into a text editor (Notepad++, Atom, Nano, etc.), and save the file with a .tar extension, you can then access the tar file.
 

SMnasMAN

Contributor
Joined
Dec 2, 2018
Messages
177
hey guys, thanks SO MUCH for all the work on these scripts (and makeing them open to other users!) its clear ALOT of work and time went into this and supporting them. - thanks!

Ive been testing/running the scripts with much success. One issue i came across was some of my SAS SSD disks (HGST) would not show up in either the smart (ofcouse) NOR IN the SASemail script. after some minor debugging this is the reason / fix (grep ing for "Serial Number" does not match as smartctl uses "Serial number" on some sas output:

So i changed one line of the auto disk scan to this (and it works!):
if [ "$(smartctl -i /dev/${drive} | grep "Serial number\|Serial Number" | awk '{print $3}')" ]

(if anyone is interested ive put my full script im using that i modiefed a bit more, so that in a single email, i get the table for SMART drives, AND the table for SAS drives + smartctl -a for ALL drives at bottom of email).


Code:
root@freenas:~/fnAUTOcfgBACKUPS # smartctl -i /dev/da19
smartctl 6.6 2017-11-05 r4594 [FreeBSD 11.2-STABLE amd64] (local build)
Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Hitachi/HGST Ultrastar 7K4000
Device Model:     HGST HUS724040ALA640
Serial Number:    PN2331PAH4KM2T
...


vs

root@freenas:~/fnAUTOcfgBACKUPS # smartctl -i /dev/da9
smartctl 6.6 2017-11-05 r4594 [FreeBSD 11.2-STABLE amd64] (local build)
Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Vendor:               HGST
Product:              HSCP0480S5xnNMRI
Revision:             3P02
...
Logical Unit id:      0x5000cca04e0c6488
Serial number:        0QV6U8SA
Device type:          disk
Transport protocol:   SAS (SPL-3)
Local Time is:        Sun Sep  1 13:57:01 2019 CDT
SMART support is:     Available - device has SMART capability.
SMART support is:     Enabled
Temperature Warning:  Enabled



Code:
#!/bin/sh

### Parameters ###
logfile="/tmp/smart_report.tmp"
smartctl=/usr/local/sbin/smartctl
email="YOU@CHANGEME.COM"
subject="big SMART Status Report (sas and sata) for FreeNAS"
#drives="da9 da10 da11"
#drives=$(for drive in $(sysctl -n kern.disks); do \
#if [ "$("${smartctl}" -i /dev/${drive} | grep "SAS" | awk '{print $3}')" ]
#then printf ${drive}" "; fi done | awk '{for (i=NF; i!=0 ; i--) print $i }')
drives=$(for drive in $(sysctl -n kern.disks); do \
if [ "$(smartctl -i /dev/${drive} | grep "Serial number\|Serial Number" | awk '{print $3}')" ]
then printf ${drive}" "; fi done | awk '{for (i=NF; i!=0 ; i--) print $i }')

tempWarn=40
tempCrit=45
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 SMART STYLE  ######
(
 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}


#logger $drives

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 (temp > tempWarn || temp > tempCrit)
         temp=temp"*"

      if (reAlloc > 0 || reAlloc > sectorsCrit)
         reAlloc=reAlloc"*"

      if (pending > 0 || pending > sectorsCrit)
         pending=pending"*"

      if (offlineUnc > 0 || offlineUnc > sectorsCrit)
         offlineUnc=offlineUnc"*"

      if (testAge > testAgeWarn)
         testAge=testAge"*"


      if (hiFlyWr == "") hiFlyWr="N/A";
      if (cmdTimeout == "") cmdTimeout="N/A";
      printf "|%-6s|%-24s| %s |%5s|%5s|%5s|%7s|%7s|%8s|%6s|%9s|%6s|%7s|%4s|\n",
      device, serial, temp, onHours, startStop, spinRetry, reAlloc, pending, offlineUnc,
      seekErrors, totalSeeks, hiFlyWr, cmdTimeout, testAge;
      }'
  ) >> ${logfile}
done

(
  echo "+------+------------------------+----+-----+-----+-----+-------+-------+--------+------+---------+------+-------+----+"
) >> ${logfile}



###### summary SAS STYLE ######
(
    echo ""
    echo "########## SMART status report summary for all drives ##########"
    echo ""
    echo "+------+---------------+----+-----+------+------+------+------+------+------+"
    echo "|Device|Serial         |Temp|Start|Load  |Defect|Uncorr|Uncorr|Uncorr|Non   |"
    echo "|      |               |    |Stop |Unload|List  |Read  |Write |Verify|Medium|"
    echo "|      |               |    |Count|Count |Elems |Errors|Errors|Errors|Errors|"
    echo "+------+---------------+----+-----+------+------+------+------+------+------+"
) >> ${logfile}
for drive in $drives
do
    (
        smartctl -a /dev/${drive} | \
        awk -v device=${drive} -v tempWarn=${tempWarn} -v tempCrit=${tempCrit} \
        -v warnSymbol=${warnSymbol} -v critSymbol=${critSymbol} '\
        /Serial number:/{serial=$3} \
        /Current Drive Temperature:/{temp=$4} \
        /start-stop cycles:/{startStop=$4} \
        /load-unload cycles:/{loadUnload=$4} \
        /grown defect list:/{defectList=$6} \
        /read:/{readErrors=$8} \
        /write:/{writeErrors=$8} \
        /verify:/{verifyErrors=$8} \
        /Non-medium error count:/{nonMediumErrors=$4} \
        END {
            if (temp > tempCrit)
                device=device " " critSymbol;
            else if (temp > tempWarn)
                device=device " " warnSymbol;
            printf "|%-6s|%-15s| %s |%5s|%6s|%6s|%6s|%6s|%6s|%6s|\n",
            device, serial, temp, startStop, loadUnload, defectList, \
            readErrors, writeErrors, verifyErrors, nonMediumErrors;
        }'
    ) >> ${logfile}
done
(
    echo "+------+---------------+----+-----+------+------+------+------+------+------+"
    echo ""
    echo ""
) >> ${logfile}

###### for each drive ######
for drive in $drives
do
    serial=`smartctl -i /dev/${drive} | grep "Serial number" | awk '{print $3}'`
    (
        echo ""
        echo "########## SMART status report for ${drive} drive (${serial}) ##########"
        smartctl -a /dev/${drive}
        echo ""
        echo ""
    ) >> ${logfile}
done
sed -i '' -e '/smartctl 6.3/d' ${logfile}
sed -i '' -e '/Copyright/d' ${logfile}
sed -i '' -e '/Compliance/d' ${logfile}
sed -i '' -e '/LU is resource/d' ${logfile}
sed -i '' -e '/Form Factor/d' ${logfile}
sed -i '' -e '/Logical Unit/d' ${logfile}
sed -i '' -e '/Device type/d' ${logfile}
sed -i '' -e '/Local Time/d' ${logfile}
sed -i '' -e '/SMART support/d' ${logfile}
sed -i '' -e '/Temperature Warning/d' ${logfile}
sed -i '' -e '/=== START OF/d' ${logfile}
sed -i '' -e '/SMART Attributes Data/d' ${logfile}
sed -i '' -e '/Drive Trip/d' ${logfile}
sed -i '' -e '/Manufactured/d' ${logfile}
sed -i '' -e '/Specified cycle count/d' ${logfile}
sed -i '' -e '/Specified load-unload/d' ${logfile}
sed -i '' -e '/Vendor/d' ${logfile}
sed -i '' -e '/Error counter/d' ${logfile}
sed -i '' -e '/SMART Self-test/d' ${logfile}
echo "</pre>" >> ${logfile}

### Send report ###
sendmail -t < ${logfile}
rm ${logfile}
 

ovizii

Patron
Joined
Jun 30, 2014
Messages
435
I've got a slightly off/topic question but does someone know off similar scripts for a Linux based system?
I'm really happy with this on my freenas but I'm looking for a similar script for another server.
 

adrianwi

Guru
Joined
Oct 15, 2013
Messages
1,231

kspare

Guru
Joined
Feb 19, 2015
Messages
508
Are there some updated scripts for the zpool and smart that work with 11.3?
 
Top