]>
git.proxmox.com Git - mirror_zfs-debian.git/blob - cmd/zed/zed.d/generic-email.sh
3 # Send email to ZED_EMAIL in response to a given zevent.
4 # This is a generic script than can be symlinked to a file in the zed
5 # enabled-scripts directory in order to have email sent when a particular
6 # class of zevents occurs. The symlink filename must begin with the zevent
7 # (sub)class string (eg, "probe_failure-email.sh" for the "probe_failure"
8 # subclass). Refer to the zed(8) manpage for details.
13 # 3: missing executable
15 test -f "${ZED_ZEDLET_DIR}/zed.rc" && .
"${ZED_ZEDLET_DIR}/zed.rc"
17 # Only send email if ZED_EMAIL has been configured.
18 test -n "${ZED_EMAIL}" ||
exit 2
20 # Ensure requisite executables are installed.
21 if ! command -v "${MAIL:=mail}" >/dev
/null
2>&1; then
22 logger
-t "${ZED_SYSLOG_TAG:=zed}" \
23 -p "${ZED_SYSLOG_PRIORITY:=daemon.warning}" \
24 `basename "$0"`: "${MAIL}" not installed
28 # Override the default umask to restrict access to the msgbody tmpfile.
31 SUBJECT
="ZFS ${ZEVENT_SUBCLASS} event"
32 test -n "${ZEVENT_POOL}" && SUBJECT="${SUBJECT} for ${ZEVENT_POOL}"
33 SUBJECT
="${SUBJECT} on `hostname`"
35 MSGBODY
="${TMPDIR:=/tmp}/`basename \"$0\"`.$$"
37 echo "A ZFS ${ZEVENT_SUBCLASS} event has been posted:"
39 echo " eid: ${ZEVENT_EID}"
40 echo " host: `hostname`"
41 echo " time: ${ZEVENT_TIME_STRING}"
42 test -n "${ZEVENT_VDEV_TYPE}" -a -n "${ZEVENT_VDEV_PATH}" && \
43 echo " vdev: ${ZEVENT_VDEV_TYPE}:${ZEVENT_VDEV_PATH}"
44 test -n "${ZEVENT_POOL}" -a -x "${ZPOOL}" && \
45 "${ZPOOL}" status
"${ZEVENT_POOL}"
48 test -f "${MSGBODY}" && "${MAIL}" -s "${SUBJECT}" "${ZED_EMAIL}" < "${MSGBODY}"
52 if test "${MAIL_STATUS}" -ne 0; then
53 logger
-t "${ZED_SYSLOG_TAG:=zed}" \
54 -p "${ZED_SYSLOG_PRIORITY:=daemon.warning}" \
55 `basename "$0"`: "${MAIL}" exit="${MAIL_STATUS}"