DEVICESCAN -m root -M test -M exec /usr/local/bin/smartd_alert
Then, create the following script at /usr/local/bin/smartd_alert. This uses yad, but as fungle says, you could use other notifications if you like. This script will pop up a message, and also mail you when smartd encounters a warning.
#!/usr/bin/env bash
NOTIFIEDUSER=<!!YOUR_USERNAME_HERE!!>
message="$(cat $1)"
sudo -u $NOTIFIEDUSER DISPLAY=:0 yad --center --title=Smartmontools --text="$message" --button=OK:0 --image "dialog-warning" --sticky
# Send mail if /usr/bin/mail exists
if ! [ -x /usr/bin/mail ]; then
echo "Your system does not have /usr/bin/mail. Install the mailx or mailutils package"
exit 1
fi
echo "$message" | /usr/bin/mail -s 'Smartmontools warning' $NOTIFIEDUSER
Give it executable permissions, then restart smartd with
$ sudo systemctl restart smartd.service
Hopefully, you should get the popup and the mail immediately. If it works fine, then turn off "testing mode" by re-editing /etc/smartd.conf and removing "-M test". i.e. it should read
DEVICESCAN -m root -M exec /usr/local/bin/smartd_alert
Finally, restart smartd.service.
Thanks again for the help, fungle!
]]>You can tell smartd to run your script instead of running the mail command. If you are not so savy at scripting, then you can try to porting the `smartd-runner` script over.
You will need to copy the directory /etc/smartmontools/run.d/ and the scripts in it and makes sure that the scripts are compatible and meet any necessary dependencies. This sentence from the ubuntu doc is especially revealing
/usr/share/smartmontools/smartd-runner is a script that basically saves the report to a temporary file, and then runs anything it finds in /etc/smartmontools/run.d/; take a look there to understand what you already have (there should be a script that mails the report).
Then you can follow the steps in the docs under the Personal Computer header that tells you how to create custom notificiations.
Good Luck.
]]>In Arch, it seems that vanilla smartmontools can only mail users and log when there are issues, which is obviously a lot slower. Is there a way to get a pop-up window as in (K)ubuntu?
FWIW I think (K)ubuntu relies on a script called smartd-runner. I tried to copy it to Arch, but not surprisingly, it failed. I also tried gsmartcontrol from the Arch repos, but this didn't appear to have an "instantaneous-warning" feature either.
]]>