zfsonlinux/zfs — pull request #2085 by dun (2014-01-29 10:28:35+00:00)
Title: Initial implementation of zed (ZFS Event Daemon)

zed monitors ZFS events. When a zevent is posted, zed will run any scripts that have been enabled for the corresponding zevent class. Multiple scripts may be invoked for a given zevent. The zevent nvpairs are passed to the scripts as environment variables. Refer to the zed(8) manpage for details.

Initial scripts have been developed to log events to syslog, automatically rebuild to a hot spare device, and send email in response to checksum, resilver.finish, and scrub.finish events. To enable email notifications, configure ZED_EMAIL in zed.rc. To enable hot sparing, uncomment ZED_SPARE_ON_IO_ERRORS and ZED_SPARE_ON_CHECKSUM_ERRORS in zed.rc. (Note that the autoexpand property is not yet supported.)

An EID (Event IDentifier) has been added to each event to uniquely identify it throughout the lifetime of the loaded ZFS kernel module; it is a monotonically increasing integer that resets to 1 each time the module is loaded. To support hot spare functionality, the following members have been added to all zevent ereports that include a vdev: vdev_spare_paths, vdev_spare_guids, vdev_read_errors, vdev_write_errors, and vdev_cksum_errors.

zed is a work-in-progress. There are still rough edges and dark corners where you may be eaten by a grue. Due to its size, I wanted to start the pull-request now while I continue on code cleanup and fixes. It has not yet been fully integrated into the spec file to start at boot.

Assimilates issue #1896 and lays the groundwork for moving forward on issue #2.