<div dir="ltr"><div dir="ltr"><div><br></div></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, 18 Nov 2023 at 12:27, Stephen Worthington <<a href="mailto:stephen_agent@jsw.gen.nz">stephen_agent@jsw.gen.nz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Sat, 18 Nov 2023 10:15:34 +0000, you wrote:<br>
<br>
>Hi Stephen,<br>
><br>
>I know that in the past you've shared some of your useful scripts and<br>
>wondered if you had anything to share which would help with automating the<br>
>smartctl reporting.<br>
><br>
>I've been running it manually every few weeks (except when I forget) and<br>
>I've caught a couple of failing drives with it - and missed one.<br>
><br>
>The bit I'm most unsure of is how to automatically interpret the results<br>
>and convert them to a warning, particularly as some of my drives report<br>
>some strange numbers in some of the checks, which I think can probably be<br>
>ignored.<br>
><br>
>I generally just go by whether the short test completes successfully but I<br>
>think I should be checking whether some of the failure counts are going up?<br>
><br>
>Thanks<br>
<br>
SmartMonTools already includes code to check for problems with the<br>
drive - so all you need to do is install and configure it correctly.<br>
Then smartd will run in the background all the time and notify you of<br>
anything you need to know about. Look at the /etc/smartd.conf file<br>
and adjust it so that it emails you on any error. I had to also<br>
customise it to tell it the type of some drives (such as the fact that<br>
my archive drives are "removable" (they are normally turned off and<br>
are only on when I want to watch a recording on one of them). So I<br>
commented out the default DEVICESCAN line, and replace it with this:<br>
<br>
#DEVICESCAN -d removable -n standby -m root -M exec<br>
/usr/share/smartmontools/smartd-runner<br>
DEFAULT -a -n standby -m root -M exec<br>
/usr/share/smartmontools/smartd-runner<br>
/dev/nvme0n1 -d nvme<br>
/dev/disk/by-label/arc1 -d sat,16 -d removable<br>
/dev/disk/by-label/arc2 -d sat,16 -d removable<br>
/dev/disk/by-label/arc3 -d sat,16 -d removable<br>
/dev/disk/by-label/arc4 -d sat,16 -d removable<br>
/dev/disk/by-label/arc5 -d sat,16 -d removable<br>
/dev/disk/by-label/arc6 -d sat,16 -d removable<br>
DEVICESCAN -a -d auto -d removable -n standby<br>
#DEVICESCAN -a -m <a href="mailto:stephen@jsw.gen.nz" target="_blank">stephen@jsw.gen.nz</a> -M test<br>
DEVICESCAN -a -m <a href="mailto:stephen@jsw.gen.nz" target="_blank">stephen@jsw.gen.nz</a> -M daily<br>
<br>
(My email client wrapped the first #DEVICESCAN line and the DEFAULT<br>
line under it - they are each one line only)<br>
<br>
It was a long time ago that I did this, so I can not remember the full<br>
details of each option, but the /dev lines just describe drives that<br>
smartd was not looking at automatically, or was using the wrong<br>
options for. You do not need them unless there are problems with the<br>
default settings. The DEFAULT and DEVICESCAN lines tell smartd what<br>
to do. The "-a" on a DEVICESCAN line tells it to scan all the drives<br>
it can find. See "man smartd.conf" for full details. I have it set<br>
up to run the smartd-runner program, which then pops up an XFCE4<br>
on-screen message and also emails me on the root account on that<br>
machine and also on my main email and my gmail accounts. The idea is<br>
that I should see one of those messages as soon as possible so I can<br>
do something about a potential failing drive. To make all that work,<br>
I think you need to install the smart-notifier package, and also a<br>
mail program to send emails with, from either the bsd-mailx package or<br>
mailutils package. The mail program needs to be configured to be able<br>
to send emails via your normal SMTP server. I do not know how to<br>
configure it to send via gmail, as I run my own SMTP server which can<br>
send to gmail for me and I just send any emails to it to handle. You<br>
could just try configuring smartd to send to your @<a href="http://gmail.com" rel="noreferrer" target="_blank">gmail.com</a> address<br>
and mail might be smart enough to do it automatically. I have MX<br>
records defined in my DNS for my <a href="http://jsw.gen.nz" rel="noreferrer" target="_blank">jsw.gen.nz</a> domain, and it finds them<br>
and sends to my main <a href="mailto:stephen@jsw.gen.nz" target="_blank">stephen@jsw.gen.nz</a> account without any further<br>
configuration. I have mailutils installed - I think that is all that<br>
is needed to make the local email accounts work on a Linux system, so<br>
that emails to addresses like root@localhost will work and can be<br>
accessed by running "mail" from the root account, or from any other<br>
account for the messages for that account.<br>
<br>
To get smartd to run, you need to edit /etc/default/smartmontools and<br>
set "start_smartd=yes", then run:<br>
<br>
sudo systemctl enable --now smartmontools<br>
<br>
The commented out -M test line is used for testing if email addresses<br>
work. Comment out your -M daily line and uncomment your -M test line<br>
and then run smartd (or restart it with "sudo systemctl restart<br>
smartmontools") and it will send a test email. Once you get that<br>
working, put the right options into the -M daily line, uncomment that<br>
and comment the -M test line and restart smartmontools.<br>
<br>
If you do install mailutils, you will probably get another daily email<br>
from the automatic database checking that gets done from<br>
/etc/cron.daily/optimize_mythdb. Without local email accounts<br>
working, those emails from anacron never get sent anywhere.<br>
<br>
These days, now that I have the Home Assistant app running on my<br>
phone, I could get Home Assistant to send a notification to my phone.<br>
And with the Tasker app I can get an audible alarm on any HA<br>
notification. I have that all set up for my mother's emergency alarm<br>
button, but have not done it for SMART errors yet.<br></blockquote><div><br></div><div>Thank you very much Stephen,<br></div><div><br></div><div>As usual a very thorough reply and much appreciated.</div><div><br></div><div>I now have smartd running and am working on getting the remote email part up.</div><div><br></div><div>I also run my own SMTP server but I've only ever connected to it from Windows boxes and it turns out that on Linux there's a bit more to</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">The mail program needs to be configured to be able to send emails via your normal SMTP server.</blockquote><div><br></div><div>...than I was expecting (at least when doing it from the command line). I'm sure I'll work that out easily enough once I get a bit of time.</div><div><br></div><div>Kind Regards,</div><div><br></div><div>D</div><div> </div></div></div>