Check HDD health - scheduled smartctl tests results to email

blackie

Vu+ Newbie
Hello, I just installed 2.5" 4TB Seagate HDD to my DUO 4K receiver.
Smartctl for the device /dev/sda1 is reporting some strange values but the it's working fine for now.
I haven't found a way how to check the HDD health (based on S.M.A.R.T attributes) via BH GUI.
So I have scheduled (via terminal and hbcron config files) and tested a weekly health test 'smartctl -t short /dev/sda1'.
In the related config file /etc/smartd.conf I can set my external email address for reporting problems found during the health test.
I'm not sure how sending emails is working on BlackHole images (which command can be used).
Or how to setup forwarding root messages to my external gmail address.
Can anyone advice how to do it?
Thank you in advance for help
 

AlexWilMac

Moderator
Surely not a basic or indispensable function... You can always connect your HDD to a PC and check its SMART status there.
Or, maybe, it can be useful this article, provided that you can download such routine for BH.

Code:
 https://www.aptgetlife.co.uk/checking-a-hard-drives-smart-status-from-the-command-line/
 

blackie

Vu+ Newbie
OK, thank you. Luckily the smartctl utility is already included in BH image, so no need to install it manually.
It's working as expected, the last missing piece is to enable smartctl sending emails during health test.
The functionality is in smartctl, in case of disk warning or failure it can send email message to selected email address with the problem description.

Seems that sendmail utility is already included in BH image, maybe it can be used to send those messages to gmail.
I plan to dig into sendmail configuration and try to make it work, hopefully it can be done in BH.
If anyone can help me with sendmail configuration pls let me know.
 

blackie

Vu+ Newbie
It took a lot time and testing but I finally have a working version of smtp client script.
It's compatible with standard mail command and supports most of its basic options.
I think it's good enough for the purpose I need, sending e-mail messages to my gmail account.
You can use it and modify if needed, hope it works for you too :)

1. Copy the script to /usr/bin/ folder.
2. Make it executable (chmod +x /usr/bin/mail).
3. Modify SMTP_AUTH_... variables according to your authentication credentials (username & password)
4. For use with other(not gmail) smtp server you need to modify variable CONN_HELPER_OPTIONS
 

Attachments

  • mail.zip
    2.2 KB · Views: 2

blackie

Vu+ Newbie
I run into some problems to enable automatic S.M.A.R.T. monitoring & sending messages.
But I finally got it resolved and it's working fine.

To enable automatic HDD smart monitoring 2 additional steps are needed.
1. configure which disk and which attributes to monitor in /etc/smartd.conf
I decided to receive email when reallocated sectors > 0 and temperature > 55 celsius, so added following line:
/dev/sda1 -a -I 194 -W 4,45,55 -R 5 -m myaddress@gmail.com
2. To enable background service smartd to monitor your HDD health every xxx seconds
you need to edit file /etc/default/smartmontools
and uncomment(remove #) from the line start_smartd=yes.
You can also uncomment and modifiy xxx seconds interval between checks in the line
smartd_opts="--interval=1800"
Don't be afraid, shorter interval is not a problem, it won't wake your HDD from standby.

Now you can start the service manually (/etc/init.d/smartd start) or by restarting your VuPlus STB.
Hope this guide will help you to save some time.
 
Top