Set up SMART Reporting via email

nick779

Contributor
Joined
Dec 17, 2014
Messages
189
Something I just happened to notice. Are you checking ada3 twice by accident or do you have an ada4 that is getting messed?

Just a copy paste error. its not on the server
 

adrianwi

Guru
Joined
Oct 15, 2013
Messages
1,231
Fantastic! Was looking for something like this, and really simple!!
 

Clinderw

Explorer
Joined
Aug 11, 2013
Messages
96
Off the cuff I'm not sure this will work for 9.3 just because there are many routine updates for this new flavor of FreeNAS.

So if you want to use this type of code, create a FreeBSD jail, open the shell for the jail, 'pkg_add-r smartmontools' and add your script. Skip steps 2 and 11 in my original posting.

This is a very quick posting as I have to run. Let me know if this works and I'll update the original posting to reflect 9.3 instructions.

Is this still the recommended approach or is there another recommended way to do this with 9.3?

Thanks for all the time putting this together.
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
I don't do this, but I don't see why this wouldn't work off the top of my head. Its definitely not a 'recommended' thing to implement because you're modifying the boot device.
 

Clinderw

Explorer
Joined
Aug 11, 2013
Messages
96
Aside from SMART monitoring set up through the GUI, what is best practice around monitoring the outputs?

I liked this because it could send me a weekly email (daily is aggressive) - if there is a better or more recommended approach would love to hear it.

Setting it up in a jail seems like a smart way to get around editing the actual boot device, no?

Cyberjock - appreciate your posts, seen you in a ton of threads i've looked at. Thanks.
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
I prefer daily because when things go bad, then generally go bad fast. And often I see a second disk fail within a week or so. So if you are doing weekly, you'll have 2 bad disks before you know any are. ;)

Hence I do nightly.
 

Clinderw

Explorer
Joined
Aug 11, 2013
Messages
96
Can you share the script or process you use?
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,970
I have changed the first entry of this thread to accommodate moving the script to another location which no longer binds it to the boot device. When I created this thread, at the time we were doing a lot of modification in the boot device, standard practice. Times change.
 

Fraoch

Patron
Joined
Aug 14, 2014
Messages
395
Thanks joeschmuck, that worked perfectly. Though I did read about moving the script off the boot device way back when you first posted it, I forgot about it and kept having to reload the script every time I updated. Lately scp made it fairly painless.

But moving it to the pool like your revised original post was very easy and worked perfectly.
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,970
Guinea Pig #1 (a.k.a. Fraoch), Thanks for the feedback and being the first one to test it. Now it will survive software updates.
 

Clinderw

Explorer
Joined
Aug 11, 2013
Messages
96
This works perfectly - thanks! Appreciate you refreshing something rather old :)
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,970
Here to support.
 

Omega3

Cadet
Joined
Nov 11, 2015
Messages
3
Thanks for taking the time to write & explain this script.
When creating the Chron Job:
Code:
/mnt/pool/scripts/sh esmart.sh /dev/ada0

Didn't work for me.

Instead, I tried:
Code:
sh /mnt/pool/scripts/esmart.sh /dev/ada0

Which seems to work fine.

Using the email from the second script I'm using gmail filter to label my emails as passed or failed SMART tests, based on if they contain the text "No Errors Logged".
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,970
@Omega3
Thanks, I did a typo and you caught it. I have fixed the error.

As for labeling your emails, you can change the email subject line in the script to whatever you like, just ensure you change only what you want changed.
 

Omega3

Cadet
Joined
Nov 11, 2015
Messages
3
@joeschmuck
Thanks for clearing that up, I got pointed in the right direction earlier in the thread. I spend a couple of hours on it this morning, which gave me a better appreciation of your script. Your comments & explanation are a great help. I'm still a novice at the command line, I think I need to use "sed" to cut cover0ada down to size, but it is not as easy as it seems!

Will park it for the time being, but will revisit this when the server is set up properly & I am more competent with the commandline.
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,970
"sed" is definitely not easy to understand and I had difficulty as well but if you find the right reference material it will help. Don't ask me what that reference material is, I searched for weeks and found many different references on the internet. I think if I found a book on the subject, it would have likely been a better reference but I was doing this on the side and didn't want to pay for a book. Maybe the local library would have helped.

Also, to be honest, the built in testing for FreeNAS actually works very well these days and will only send you an email when there is a problem. The downside with that is you must take it on faith that the tests are being run. Myself, I manually check the SMART stats on my drives every month or so and can see that the short and long tests are being conducted and I can see the full health.
 

barny

Dabbler
Joined
Feb 4, 2015
Messages
15
Joeschmuck
Thanks for the work you put into the script. As I started working down through your scripts I used the one on 4/28/12. I put your script in the /conf/base/etc file as listed in the code and made chron point to it. I noticed in post 108 that there was a change made and it should be put in /mnt/pool/scripts instead. Is there some danger in having it there in /conf/base/etc? I have it at present in the conf/base/etc/ and it seems to be working. I made a short as well as a long test file for chron to run. I love the fact that it emails the results on a regular basis. Thank you for your script.
 
Last edited:

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,970
There is nothing wrong with leaving it in the location you have it in however it may not survive a software upgrade. If you find this the case then I'd recommend moving it to the pool instead. That really was the only reason for moving it, because many folks using this found that occasionally they would have to copy the script back after an upgrade.
 

barny

Dabbler
Joined
Feb 4, 2015
Messages
15
There is nothing wrong with leaving it in the location you have it in however it may not survive a software upgrade. If you find this the case then I'd recommend moving it to the pool instead. That really was the only reason for moving it, because many folks using this found that occasionally they would have to copy the script back after an upgrade.

Thanks Joe! Really appreciate the effort you put into it.
 

Wolfeman0101

Patron
Joined
Jun 14, 2012
Messages
428
I have Short Tests running every 2 days and a Long Test on the 8th and 22nd. I have my email output but I just want to make sure everything is working right and also what should I be looking for in this email to avoid possible HDD failures.

http://pastebin.com/tTvZsmFw
 
Top