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

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
I am hoping someone can help me out. I have the original script for SATA drives installed on Freenas 9.x and then I upgrade to 11.2x a while back and ever since then its not working. I am not great with CLI. Is there a new script I need to install? Is there instructions on how to do it?
Did you try the latest version? It's available here:
 
Joined
May 12, 2017
Messages
6
1st, thank you @Spearfoot for your work on these helpful scripts. I have been using them for several years on a few machines.
I just upgraded one of my machines to TrueNAS 12 RC1 and the zpool_report.sh causes the following to be emailed to me, repeats for each pool:
date: illegal option -- 0
usage: date [-jnRu] [-d dst] [-r seconds|file] [-t west] [-v[+|-]val[ymwdHMS]]
[-I[date | hours | minutes | seconds]]
[-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format]

I updated to the latest script on git, with same result.
Has anyone else had this issue after upgrading to 12RC1?

Thanks!
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
1st, thank you @Spearfoot for your work on these helpful scripts. I have been using them for several years on a few machines.
I just upgraded one of my machines to TrueNAS 12 RC1 and the zpool_report.sh causes the following to be emailed to me, repeats for each pool:
date: illegal option -- 0
usage: date [-jnRu] [-d dst] [-r seconds|file] [-t west] [-v[+|-]val[ymwdHMS]]
[-I[date | hours | minutes | seconds]]
[-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format]

I updated to the latest script on git, with same result.
Has anyone else had this issue after upgrading to 12RC1?

Thanks!
You're very welcome!
I don't have an installation of TrueNAS 12 RC1 to experiment with, so I can't research the problem you're having. I may install TrueNAS as a VM once a stable version has been released.
 

Mike05

Cadet
Joined
Dec 12, 2016
Messages
5
Birkir Brimdal: I have had the same error, and it seems to be related to the different format of the zpool status output with TrueNAS 12 vs FreeNAS 11.3.

I made the following changes to the script I have in order to get it working on my TrueNAS 12.0-RELEASE server (search for the first word to find the correct location in the script). Note that I have v1.3 of the script that was modified by melp, mentioned here, which reports in html format. It may be slightly different to Bidule0hm's script. It's the parameters given to awk that are important.

EDIT: I believe Spearfoot has managed this in his latest zpool_report.sh script by checking the BSD release and changing the awk parameters accordingly. They match my updated awk parameters.

1. scrubErrors="$(echo "$statusOutput" | grep "scan" | awk '{print $8}')"
It was ... awk '{print $10}' in the previous output format

2. scrubDate="$(echo "$statusOutput" | grep "scan" | awk '{print $15"-"$12"-"$13"_"$14}')"
It was ... awk '{print $17"-"$14"-"$15"_"$16}' in the previous output format

3. scrubTime="$(echo "$statusOutput" | grep "scan" | awk '{print $6}')"
It was ... awk '{print $8}' in the previous output format

4. if [ "$scrubRepBytes" != "N/A" ] && [ "$scrubRepBytes" != "0B" ]; then scrubRepBytesColor="$warnColor"; else scrubRepBytesColor="$bgColor"; fi
The "0B" was "0" in the previous output format.

These changes should fix the incorrect entries in the "Zpool Status Report Summary" table and prevent the error relating to the illegal operation with the date command.

Hope this helps,
Mike.
 
Last edited:

thepixelgeek

Patron
Joined
Jan 21, 2016
Messages
271
Not sure if this was mentioned already, but I'm noticing a "?" next to the drive name. What does it mean?
1609287077174.png
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
Not sure if this was mentioned already, but I'm noticing a "?" next to the drive name. What does it mean?
View attachment 43841
It means you have something out of tolerance, possibly the temperature or some other item above the setpoint. Did you read the notes and the script you are using? You should do that.
 

thepixelgeek

Patron
Joined
Jan 21, 2016
Messages
271
@joeschmuck Looking for notes, using Spearfoot's script. Perhaps I've had too much to drink, but don't see any.

Edit: I do see warnSymbol="?" in the script, but not the explanation.
 

thepixelgeek

Patron
Joined
Jan 21, 2016
Messages
271
Perhaps it's due to the astresk on test age? See below image. Ada7 and da7 are brand new drives recently resilvered. Ada2 and 0 are SSD's not being used. Ada3 (SSD) is a boot drive.

1609370207771.png
 

Attachments

  • 1609370180925.png
    1609370180925.png
    35 KB · Views: 299

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
Perhaps I've had too much to drink, but don't see any.
LOL, perhaps, I might have forgot that not everyone can interpret scripts, I'm still learning with the odd nuances between BSD, Linux, and all the variants in between.

So if you take a look at the script (it's almost in English), line 19 defines the "?" as the Warning Symbol. Line 18 defines the Test Age Warning to be greater than 1 day (you need to read more of the code to determine that and it actually decodes to a SMART Short or Long test has passed within the last 24 hours (testAgeWarn * 24) at the time this script is run.) And as you ascertained the "*" asterisks identify the alarm indication which in this case are also provided as days since that last SMART Test was run to pass. Keep in mind that you are being alerted to a Warning, not a failure in this case.

If you go and look at the SMART data to each drive (should be in the automated email) then you can see what SMART is reporting for the drives. You may not have a test scheduled for all the drives even though you might think you do. Double check it.

You can change the script if you desire to change the testAgeWarn=7 or some other value if you like. Make the script work for you. This is the same for sectorsCrit=10, I have my setting at 1 because if there is a single failure, I want to know about it right away. Same thing for the drive temperatures.

So while I didn't have too much to drink tonight, I am tired and can barely see through my eyes. Got up very early to send my daughter on the road headed back home. If you have any questions about the script, ask. I'm not online every day but someone will answer or I will eventually get back to you.

Also, all your drive temps look great, all the other values look good too, except for the SMART test ages for the few drives indicating a warning.
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
Perhaps it's due to the astresk on test age? See below image. Ada7 and da7 are brand new drives recently resilvered. Ada2 and 0 are SSD's not being used. Ada3 (SSD) is a boot drive.

View attachment 43861
You're correct -- the script is warning you that the indicated disks have not been tested recently.
 

thepixelgeek

Patron
Joined
Jan 21, 2016
Messages
271

fostersimported

Dabbler
Joined
Jul 25, 2011
Messages
19
Hi,
I have the smart script working, but cannot work out why the table is not formating in my e-mail. Can anyone help?
This is my email.

email.png


When I check the tmp file the script creates it is formatted in a table.

log.png


Cheers
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
Hi,
I have the smart script working, but cannot work out why the table is not formating in my e-mail. Can anyone help?
This is my email.

View attachment 44724

When I check the tmp file the script creates it is formatted in a table.

View attachment 44725

Cheers
You're running an older version of the script. I had to add proper MIME encoding to make it work better with recent versions of FreeNAS/TrueNAS. You can download the latest version here: https://github.com/Spearfoot/FreeNAS-scripts
 

Sjöhaga

Dabbler
Joined
Apr 17, 2016
Messages
41
Today I thought I hade broken the script but after some research I realised it wasn't my fault but rather WD.
The script reported a very high 'Last Test Age'.

Turns out the smart log rolls over at 65k hours for the old WD Red WD40EFRX drives :smile:.

1634043392665.png
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
Today I thought I hade broken the script but after some research I realised it wasn't my fault but rather WD.
The script reported a very high 'Last Test Age'.

Turns out the smart log rolls over at 65k hours for the old WD Red WD40EFRX drives :smile:.

View attachment 49872
Yep, looks like Western Digital used a 2-byte unsigned integer to store the power-on hours, and it wrapped after 65535 hours. That's pretty good service from a 'Red' disk!
 

Sjöhaga

Dabbler
Joined
Apr 17, 2016
Messages
41
POH is keeping up in attributes data, but not in the smart log, so the test age division gets funky :smile: .

1634047074756.png


But I think this is one of those bugs we don't really need to fix :grin:.
POH keep increasing in the attributes data so it's not completely broken.

And now I know I can't replace those drives. I want to know how long they will last :D. 2014 wan't that long ago, was it...
 

asciutto

Cadet
Joined
Jan 13, 2022
Messages
3
I got the script to run but it would not email me. Is there something within TrueNAS I'm missing? I have an email setup for the root user as well. I'm very new to all this..
 
Top