zprop: fix value help for ZPOOL_PROP_CAPACITY
[zfs.git] / cmd / zed / zed.d / data-notify.sh
blob9846769b11013062b374f7d3818e184b2972216e
1 #!/bin/sh
2 # shellcheck disable=SC2154
4 # Send notification in response to a DATA error.
6 # Only one notification per ZED_NOTIFY_INTERVAL_SECS will be sent for a given
7 # class/pool/[vdev] combination. This protects against spamming the recipient
8 # should multiple events occur together in time for the same pool/[vdev].
10 # Exit codes:
11 # 0: notification sent
12 # 1: notification failed
13 # 2: notification not configured
14 # 3: notification suppressed
15 # 9: internal error
17 [ -f "${ZED_ZEDLET_DIR}/zed.rc" ] && . "${ZED_ZEDLET_DIR}/zed.rc"
18 . "${ZED_ZEDLET_DIR}/zed-functions.sh"
20 [ -n "${ZEVENT_POOL}" ] || exit 9
21 [ -n "${ZEVENT_SUBCLASS}" ] || exit 9
22 [ -n "${ZED_NOTIFY_DATA}" ] || exit 3
24 rate_limit_tag="${ZEVENT_POOL};${ZEVENT_VDEV_GUID:-0};${ZEVENT_SUBCLASS};notify"
25 zed_rate_limit "${rate_limit_tag}" || exit 3
27 umask 077
28 note_subject="ZFS ${ZEVENT_SUBCLASS} error for ${ZEVENT_POOL} on $(hostname)"
29 note_pathname="$(mktemp)"
31 echo "ZFS has detected a data error:"
32 echo
33 echo " eid: ${ZEVENT_EID}"
34 echo " class: ${ZEVENT_SUBCLASS}"
35 echo " host: $(hostname)"
36 echo " time: ${ZEVENT_TIME_STRING}"
37 echo " error: ${ZEVENT_ZIO_ERR}"
38 echo " objid: ${ZEVENT_ZIO_OBJSET}:${ZEVENT_ZIO_OBJECT}"
39 echo " pool: ${ZEVENT_POOL}"
40 } > "${note_pathname}"
42 zed_notify "${note_subject}" "${note_pathname}"; rv=$?
43 rm -f "${note_pathname}"
44 exit "${rv}"