teeth_03
Posts: 284
Joined: Sat Sep 08, 2012 12:02 am

Detect bad hard drive and alert?

Sun Jun 23, 2013 10:10 am

I have my headless Nasberry Pi setup and working great, with a 2nd drive to backup using sync.

The question is, is there some way to have the Pi detect if either of the drives start to go bad on me? If so, is there a way to have it send an alert? I would be fine if it wrote like an ALERT.txt to the root of my share folder with details on the error.

I am still very much a n00b, so if its possible, I would need step by step instructions.

freemanbubu
Posts: 111
Joined: Sun Jun 17, 2012 11:12 am

Re: Detect bad hard drive and alert?

Mon Jun 24, 2013 9:22 am

Hi,

You can use Nagios to monitor your Pi;
Nagios can alert you (log, mail, webInterface) if a drive "disappear" or is full (80-85-90%....)

I don't know if nagios support S.M.A.R.T. diagnostics.....

teeth_03
Posts: 284
Joined: Sat Sep 08, 2012 12:02 am

Re: Detect bad hard drive and alert?

Tue Jun 25, 2013 10:21 pm

I will know pretty quickly if its offline or getting full since I access it from Windows, but it would be nice to know if there are any low level errors on either of my 2 drives.

Are there any command line utilities that can be scheduled in cron like once a month to do a full scan on both drives for bad sectors and write a log in a specified directory?

ghans
Posts: 7880
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Detect bad hard drive and alert?

Wed Jun 26, 2013 7:06 am

Code: Select all

sudo apt-get update
sudo apt-get install smartmontools
Read up on smartd , you could use it to monitor your
drive.

AFAIK debian checks filesytems every 30 mounts (reboots)
or 6 months automatically.

You can check the set interval via

Code: Select all

tune2fs -l /dev/diskname
Replace diskname with mmcblk0p2 for the SD Card and with
sda for the first USB drive.

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

teeth_03
Posts: 284
Joined: Sat Sep 08, 2012 12:02 am

Re: Detect bad hard drive and alert?

Wed Jun 26, 2013 10:24 am

Alright, I see where I can do this command that will scan and email warnings:


smartctl -d ata -t long -m [email protected] /dev/sda

Does that look about right? I'm going to follow this guide to setup email

http://www.slideshare.net/SeggySegaran/ ... -an-e-mail

ghans
Posts: 7880
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Detect bad hard drive and alert?

Wed Jun 26, 2013 1:31 pm

I think that should be a line in the smartd.conf instead.

I did not look at the tutorial , but i believe you should
install and configure ssmtp or nullmailer instead of a
full-fledged MTA.

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

teeth_03
Posts: 284
Joined: Sat Sep 08, 2012 12:02 am

Re: Detect bad hard drive and alert?

Wed Jun 26, 2013 1:53 pm

I think I might have it, slight problem though

When the Pi sends an email, I get it, but it also sends an email like this from Google:


Delivery to the following recipient failed permanently:

     [email protected]

Technical details of permanent failure:
DNS Error: Domain name not found

Where does the DNS error come from?

ghans
Posts: 7880
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Detect bad hard drive and alert?

Wed Jun 26, 2013 2:05 pm

How do send this email (any configs changed) ?
Where do you send this email to ?
Where do you read this email ?


I'm pretty much sure that "naspi" is your local hostname , and
not available through the global DNS , hence the DNS error.

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

ghans
Posts: 7880
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Detect bad hard drive and alert?

Wed Jul 10, 2013 12:36 pm

Set the MAILTO variable to an empty string at the start of your crontab ,
and completely handle the emails yourself inside of the script(s).

ghans

http://www.cyberciti.biz/faq/disable-th ... b-command/
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

Return to “Networking and servers”