Alerting the user for disk errors

User avatar
NeverSimple
Posts: 114
Joined: Sat Aug 21, 2010 4:26 pm
Location: The Netherlands

Re: Alerting the user for disk errors

Postby NeverSimple » Mon Jan 03, 2011 6:38 am

I've got the outgoing mail from the server to work without changing my hostname. For people having the same problem I wrote it down. Remember: I'm no sendmail expert and can't guarantee this will work in your setup.

If your server hostname can not be resolved in DNS, your email may be rejected. Sendmail gives you the following error:

553 5.1.8 <user@hda.home>... Domain of sender address user@hda.home does not exist

The 'genericstable' feature of sendmail can be used to rewrite the sender's address.

After you used Guillaume Boudreau's fine instructions on the Wiki, (http://wiki.amahi.org/index.php/Enable_Outgoing_Emails) add the following to the /etc/mail/sendmail.mc file:

Code: Select all

FEATURE(masquerade_envelope)dnl FEATURE(`genericstable', `hash -o /etc/mail/genericstable') GENERICS_DOMAIN(`hda.home')
NOTE: replace 'hda.home' with the hostname of the hda:

Code: Select all

hostname -f
The receiving mail server only seems to be concerned about the domain part of the senders address, so the mail address doesn't actually have to exist (you can't reply to it anyway). I used the DDNS name for my HDA (the xxx.yourhda.com address). You can find that by logging into your account on http://www.amahi.org

Make an /etc/mail/genericstable file:

Code: Select all

root root@xxx.yourhda.com root@hda.home root@xxx.yourhda.com
(again, replace hda.home with the hostname of the hda and of course, the xxx.yourhda.com, with your actual DDNS address)

Then do:

Code: Select all

cd /etc/mail makemap hash /etc/mail/genericstable < /etc/mail/genericstable make service sendmail restart
After doing the above, mail with a sender's address of root@hda.home should be rewritten to root@xxx.yourhda.com

This seems to keep my ISP's mailserver happy and I can now receive mail from my HDA. Now we only have to wait for more diagnostic mail's to be sent besides greyhole....

Richard

User avatar
bigfoot65
Project Manager
Posts: 11241
Joined: Mon May 25, 2009 4:31 pm

Re: Alerting the user for disk errors

Postby bigfoot65 » Mon Jan 03, 2011 8:31 am

Would you mind adding this to the wiki? It would be useful for others to follow. I will have to give it a try myself.
ßîgƒσστ65
Applications Manager

User avatar
NeverSimple
Posts: 114
Joined: Sat Aug 21, 2010 4:26 pm
Location: The Netherlands

Re: Alerting the user for disk errors

Postby NeverSimple » Mon Jan 03, 2011 9:03 am

If you'll give it a try, I'll wait with adding this to the WiKi after you report back. There is a lot of 'googled smartness' in the instructions and I'm not sure if it's generic enough to be applicable in most cases.

Richard

User avatar
bigfoot65
Project Manager
Posts: 11241
Joined: Mon May 25, 2009 4:31 pm

Re: Alerting the user for disk errors

Postby bigfoot65 » Mon Jan 03, 2011 7:18 pm

I tried and it did not work on my VM. Not sure if I did something wrong. Maybe someone else can try it.
ßîgƒσστ65
Applications Manager

User avatar
NeverSimple
Posts: 114
Joined: Sat Aug 21, 2010 4:26 pm
Location: The Netherlands

Re: Alerting the user for disk errors

Postby NeverSimple » Tue Jan 04, 2011 11:43 am

What exactly didn't work? Did the mail get rejected by your ISP? And if so, could you see for what reason?. Any 'xxx.yourhda.com' domain doesn't have a MX record associated with it , just an A record. This could also be a reason for an ISP to reject mail coming from such a domain. If that seems to be the case you can substitute the replacement address in the genericstable for any real address and try again.

Richard

User avatar
NeverSimple
Posts: 114
Joined: Sat Aug 21, 2010 4:26 pm
Location: The Netherlands

Re: Alerting the user for disk errors

Postby NeverSimple » Sun Jan 09, 2011 6:35 pm

There was still something strange going on with the sendmail setup: If I used the line in one of the posts above

Code: Select all

echo test 1 2 | mail -s "Some test message" someone@gmail.com
to test the mail forwarding it worked fine. The mail was forwarded to my external mail address. However, mail from greyhole stayed on the server.

I decided to change the /etc/aliases file: on the bottom of the file is a line that's commented out:

Code: Select all

# Person who should get root's mail root: realaddress@yourprovider.com
I've changed the alias after root: to one of my own real, existing e-mail addresses. After that it worked, and greyhole's status mail's were send to my external address.
I fully believe that this is not the best way to setup mail to an external address, but until someone with some real sendmail knowledge steps in, ill keep it this way :P

Back to the original topic: Alerting the user for disk errors

I found that the package 'smartmontools' (http://smartmontools.sourceforge.net/) was already present and setup on my system but wasn't running. smartmontools is a free software package that can monitor S.M.A.R.T. attributes and run hard drive self-tests. Basically, S.M.A.R.T. may give you enough of a warning that you can safely backup all your data before your hard drive dies. Obviously, nothing replaces regular backups, but it's absolutely better than knowing nothing!

If it isn't installed on your system you can do that by using a terminal as root:

Code: Select all

$ yum -y install smartmontools
smartmontools comes with two programs: smartctl which is meant for interactive use and smartd which continuously monitors S.M.A.R.T.

You can do a quick test to see if it recognizes your drives:

Code: Select all

$ smartctl -i /dev/sda
(replace /dev/sda by the drive(s) present on your system)

To setup smartd to monitor your system automatically, edit the file /etc/smartd.conf: check for a line that begins with DEVICESCAN. Comment it out by adding a ‘#’ to the beginning of the line. Add the following line to /etc/smartd.conf:

Code: Select all

/dev/sda -n standby -a -I 194 -W 6,45,55 -R 5 -M daily -M test -m root@hda.home.com
I've used an example from the config file that I modified to suit my needs.
  • '/dev/sda' is the drive you want to monitor
    '-n standby' will not wake up the drive if it is 'sleeping' or in 'standby' to poll it for status
    '-a' contains the most common options. you probably want this
    '-I 194' don't monitor normalized temperature changes, but...
    '-W 6,45,5' track temperature changes >= 6 Celsius, report temperatures >= 45 Celsius; send mail when temperature >= 55 celcius
    '-R 5' changes in Raw value of Reallocated Sector Count.
    '-M daily' send reports daily. (The default is to send only one warning email for each type of disk problem)
    '-M test' send a single test email immediately upon smartd startup. This allows one to verify that email is delivered correctly.
    '-m root@hda.home.com' Send a warning email to the email address root@hda.home.com (replace that with root@your_systems_hostname)
You'll need a line like that for every drive in the server you want to monitor.
I'd advice you to check the man page for smartd to see all the available options. There are a lot of them....

Start the daemon with:

Code: Select all

service smartd start
If you want it to restart after a reboot:

Code: Select all

chkconfig smartd on
It seems to work on my system, but so far my drives are fine and I dont have a lot to report (lucky me!). The test mails for all my drive were forwarded properly. Smartd uses as default location for notifications and warnings /var/log/messages. You can check this to monitor it's operation

I'll report back if I have more information and/or additions.

It would be nice if the development time could find a way to integrate this into Amahi!

Richard

moncapitaine
Posts: 39
Joined: Fri Jun 11, 2010 3:40 am
Location: East Germany

Re: Alerting the user for disk errors

Postby moncapitaine » Mon Mar 14, 2011 11:16 am

If you have agmail account, you could also use postfix instead of sendmail.
Sendmail did not workor me with f14 after upgrade, so i use this:http://wiki.amahi.org/index.php/Outgoing_mail_via_gmail
Celeron G530, 8GB RAM, Intel SDD 80GB system, 8TB Storage. Fileserver and Mediaserver.

User avatar
bigfoot65
Project Manager
Posts: 11241
Joined: Mon May 25, 2009 4:31 pm

Re: Alerting the user for disk errors

Postby bigfoot65 » Tue Mar 15, 2011 7:22 pm

I tried the wiki how to and it did not work for me :( Not sure what I did wrong, but the mail was rejected by the HDA.
ßîgƒσστ65
Applications Manager

Who is online

Users browsing this forum: No registered users and 1 guest