7

I have a FreeBSD file server with a 10TB array in RAID-Z (so 8TB usable with 2TB redundancy). I am trying to figure out how to get the system to notify me, preferably by email, if one of the drives fail. This is because the machine runs without a screen, and is rarely logged into directly.

I want a notification because otherwise our only hint that something has gone wrong is when a second drive goes and takes data with it.

notpeter
  • 3,505
  • 1
  • 24
  • 44
Aatch
  • 173
  • 4
  • Do you have any server monitoring software? Syslog server? If so, have the one of those do the notifications. – xeon May 02 '11 at 21:42
  • No server monitoring systems, this is a home set-up so I figure that would probably be veering into overkill technology – Aatch May 03 '11 at 21:58

5 Answers5

7

Add this to /etc/periodic.conf:

daily_status_zfs_enable="YES"

Then you will have the status of your zfs pool added to the daily periodic emails that are sent. If you currently aren't receiving them you could add your email address in also via the variable:

daily_output="your@email.com"

Erik
  • 271
  • 1
  • 2
  • +1 for mentioning [periodic(8)](http://www.freebsd.org/cgi/man.cgi?query=periodic&apropos=0&sektion=8&manpath=FreeBSD+8.2-RELEASE&format=html). These tools are already there, you just need to turn them on with [echo 'daily_status_zfs_enable="YES"' >> /etc/periodic.conf](http://www.freebsd.org/doc/handbook/filesystems-zfs.html). And while your at it, check out the [sysutils/zfs-periodic](http://www.neces.com/blog/technology/integrating-freebsd-zfs-and-periodic-snapshots-and-scrubs) port as well. – Stefan Lasiewski May 26 '11 at 23:00
3

You could try something that queries and parses the output of zpool status via cron/email. Or a commercial solution at: http://www.santools.com/smartmonux.html

ewwhite
  • 194,921
  • 91
  • 434
  • 799
  • I didn't think of a cron job, I'll probably just parse the output of `zpool status` and have it check for a specific string, then email me. – Aatch May 03 '11 at 21:59
  • It's not necessary to reinvent the wheel. As @Erik shows, this stuff is already available as a FreeBSD periodic cronjob, which would allow you to re-use the standard email and monitoring facilities, which are better tested then your own homegrown script. – Stefan Lasiewski May 26 '11 at 22:58
2

chkdsk is one script you could run via cron that when properly configured will email you when zpool errors are detected.

sciurus
  • 12,493
  • 2
  • 30
  • 49
1

For direct monitoring you can use 'zpool status -x' which will give script-friendly output. It will either say "all pools are healthy" or list pools that have errors or are unavailable.

eirescot
  • 554
  • 4
  • 8
0

If you have your cron setup to send emails, simply drop this one-liner. It will print to stderr if there's an error detected, which cron will trigger into an email.

MAILTO=foo@domain.com

# Check for zpool errors every 30 minutes
*/30 * * * * /sbin/zpool status -x | grep -v 'all pools are healthy' 1>&2
Stephen Wood
  • 133
  • 1
  • 5