Jump to content

E-Mail notification in case of a drive failure (Ubuntu)

Senzelian

I have a Plex server running on Ubuntu 22.04 LTS and I'd like to receive an e-mail in case a hard drive would fail.

How would I go about doing this?聽

I saw some guides for "mdadm", but was very confused when none of the guides seem to mention how to set up the necessary SMTP account for sending out emails. They only seem to describe how to set up the target email address.聽

Link to comment
Share on other sites

Link to post
Share on other sites

If you have the ability to trigger a script on drive failure, then you should be able to write a script that uses e.g. mailx to send an email somewhere using authenticated SMTP: https://bgstack15.wordpress.com/2017/08/05/send-authenticated-gmail-from-cli-with-mailx/

Remember to either quote or @mention others, so they are notified of your reply

Link to comment
Share on other sites

Link to post
Share on other sites

Quote

I saw some guides for "mdadm", but was very confused when none of the guides seem to mention how to set up the necessary SMTP account for sending out emails. They only seem to describe how to set up the target email address.聽

They assume you have mail already set up.

If your server can't mail out by itself, you could relay to an external mail server.

Take a peek here for what I think is a good tip in the replies:

https://unix.stackexchange.com/questions/36982/can-i-set-up-system-mail-to-use-an-external-smtp-server

Example of a bash script to check smart status:

https://csidiropoulos.wordpress.com/2013/12/13/bash-script-to-monitor-hard-disk-health-and-send-an-e-mail-on-error/

You should be able to consolidate that into something that fits your purpose.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now