]> git.proxmox.com Git - mirror_zfs-debian.git/blame - cmd/zed/zed.d/checksum-notify.sh
Imported Upstream version 0.6.5.3
[mirror_zfs-debian.git] / cmd / zed / zed.d / checksum-notify.sh
CommitLineData
e10b0808
AX
1#!/bin/sh
2#
3# Send notification in response to a CHECKSUM, DATA, or IO error.
4#
5# Only one notification per ZED_NOTIFY_INTERVAL_SECS will be sent for a given
6# class/pool/[vdev] combination. This protects against spamming the recipient
7# should multiple events occur together in time for the same pool/[vdev].
8#
9# Exit codes:
10# 0: notification sent
11# 1: notification failed
12# 2: notification not configured
13# 3: notification suppressed
14# 9: internal error
15
16[ -f "${ZED_ZEDLET_DIR}/zed.rc" ] && . "${ZED_ZEDLET_DIR}/zed.rc"
17. "${ZED_ZEDLET_DIR}/zed-functions.sh"
18
19[ -n "${ZEVENT_POOL}" ] || exit 9
20[ -n "${ZEVENT_SUBCLASS}" ] || exit 9
21
22if [ "${ZEVENT_SUBCLASS}" != "checksum" ] \
23 && [ "${ZEVENT_SUBCLASS}" != "data" ] \
24 && [ "${ZEVENT_SUBCLASS}" != "io" ]; then
25 zed_log_err "unsupported event class \"${ZEVENT_SUBCLASS}\""
26 exit 9
27fi
28
29rate_limit_tag="${ZEVENT_POOL};${ZEVENT_VDEV_GUID:-0};${ZEVENT_SUBCLASS};notify"
30zed_rate_limit "${rate_limit_tag}" || exit 3
31
32umask 077
33note_subject="ZFS ${ZEVENT_SUBCLASS} error for ${ZEVENT_POOL} on $(hostname)"
34note_pathname="${TMPDIR:="/tmp"}/$(basename -- "$0").${ZEVENT_EID}.$$"
35{
36 [ "${ZEVENT_SUBCLASS}" = "io" ] && article="an" || article="a"
37
38 echo "ZFS has detected ${article} ${ZEVENT_SUBCLASS} error:"
39 echo
40 echo " eid: ${ZEVENT_EID}"
41 echo " class: ${ZEVENT_SUBCLASS}"
42 echo " host: $(hostname)"
43 echo " time: ${ZEVENT_TIME_STRING}"
44
45 [ -n "${ZEVENT_VDEV_TYPE}" ] && echo " vtype: ${ZEVENT_VDEV_TYPE}"
46 [ -n "${ZEVENT_VDEV_PATH}" ] && echo " vpath: ${ZEVENT_VDEV_PATH}"
47 [ -n "${ZEVENT_VDEV_GUID}" ] && echo " vguid: ${ZEVENT_VDEV_GUID}"
48
49 [ -n "${ZEVENT_VDEV_CKSUM_ERRORS}" ] \
50 && echo " cksum: ${ZEVENT_VDEV_CKSUM_ERRORS}"
51
52 [ -n "${ZEVENT_VDEV_READ_ERRORS}" ] \
53 && echo " read: ${ZEVENT_VDEV_READ_ERRORS}"
54
55 [ -n "${ZEVENT_VDEV_WRITE_ERRORS}" ] \
56 && echo " write: ${ZEVENT_VDEV_WRITE_ERRORS}"
57
58 echo " pool: ${ZEVENT_POOL}"
59
60} > "${note_pathname}"
61
62zed_notify "${note_subject}" "${note_pathname}"; rv=$?
63rm -f "${note_pathname}"
64exit "${rv}"