]>
git.proxmox.com Git - mirror_zfs-debian.git/blob - cmd/zed/zed.d/resilver.finish-email.sh
3 # Send email to ZED_EMAIL in response to a RESILVER.FINISH or SCRUB.FINISH.
4 # By default, "zpool status" output will only be included in the email for
5 # a scrub.finish zevent if the pool is not healthy; to always include its
6 # output, set ZED_EMAIL_VERBOSE=1.
11 # 3: missing executable
12 # 4: unsupported event class
15 test -f "${ZED_ZEDLET_DIR}/zed.rc" && .
"${ZED_ZEDLET_DIR}/zed.rc"
17 test -n "${ZEVENT_POOL}" ||
exit 5
18 test -n "${ZEVENT_SUBCLASS}" ||
exit 5
20 if test "${ZEVENT_SUBCLASS}" = "resilver.finish"; then
22 elif test "${ZEVENT_SUBCLASS}" = "scrub.finish"; then
25 logger
-t "${ZED_SYSLOG_TAG:=zed}" \
26 -p "${ZED_SYSLOG_PRIORITY:=daemon.warning}" \
27 `basename "$0"`: unsupported event class
\"${ZEVENT_SUBCLASS}\"
31 # Only send email if ZED_EMAIL has been configured.
32 test -n "${ZED_EMAIL}" ||
exit 2
34 # Ensure requisite executables are installed.
35 if ! command -v "${MAIL:=mail}" >/dev
/null
2>&1; then
36 logger
-t "${ZED_SYSLOG_TAG:=zed}" \
37 -p "${ZED_SYSLOG_PRIORITY:=daemon.warning}" \
38 `basename "$0"`: "${MAIL}" not installed
41 if ! test -x "${ZPOOL}"; then
42 logger
-t "${ZED_SYSLOG_TAG:=zed}" \
43 -p "${ZED_SYSLOG_PRIORITY:=daemon.warning}" \
44 `basename "$0"`: "${ZPOOL}" not installed
48 # For scrub, suppress email if pool is healthy and verbosity is not enabled.
49 if test "${ZEVENT_SUBCLASS}" = "scrub.finish"; then
50 HEALTHY
=`"${ZPOOL}" status -x "${ZEVENT_POOL}" | \
51 grep "'${ZEVENT_POOL}' is healthy"`
52 test -n "${HEALTHY}" -a "${ZED_EMAIL_VERBOSE:=0}" = 0 && exit 2
55 "${MAIL}" -s "ZFS ${ZEVENT_SUBCLASS} event for ${ZEVENT_POOL} on `hostname`" \
57 A ZFS pool has finished ${ACTION}:
61 time: ${ZEVENT_TIME_STRING}
62 `"${ZPOOL}" status "${ZEVENT_POOL}"`
66 if test "${MAIL_STATUS}" -ne 0; then
67 logger
-t "${ZED_SYSLOG_TAG:=zed}" \
68 -p "${ZED_SYSLOG_PRIORITY:=daemon.warning}" \
69 `basename "$0"`: "${MAIL}" exit="${MAIL_STATUS}"