Sunday, February 27, 2011

Smart monitoring of harddiscs

Now we have exim4 email setup on our server, it would be nice to get alerts of impending doom for our harddiscs. So let's setup smart monitoring with smartmontools.

First install smartmontools
  apt-get install smartmontools

Next configure the daemon so it may start
  pico /etc/default/smartmontools
and change the following line so it says YES like here:

Now we edit /etc/smartd.conf for the configuration
  pico /etc/smartd.conf

comment out the line (or any lines in your config that are not commented out)

DEVICESCAN -d removable -n standby -m root -M exec /usr/share/smartmontools/smartd-runner
and add this line:
DEVICESCAN -m root -d sat -M test -s (S/../.././02|L/../../6/03)

That line means:
-m root = mail root in case of issues (root should have an email alias in /etc/aliases!)
-d sat = we have sata devices (you might want to change this if you're still using IDE discs)
-M test = mail us when things go wrong, subject TEST
-s (S/../.././02|L/../../6/03) = do a short selftest every night at 2, and a long test on saturday at 3

having that explained, let's start our smart daemon
  /etc/init.d/smartmontools start

after a few second the test email should arrive, which it will for every harddisc, on every restart of smartmontools (so also on server reboot). So now we instantly know when our hard discs will fail, and our server reboots :)

For more info on how to configure smartd.conf, type:
  man smartd.conf

No comments:

Post a Comment