Path: blob/main/sys/contrib/openzfs/cmd/zed/zed.d/data-notify.sh
48529 views
#!/bin/sh1# shellcheck disable=SC21542#3# Send notification in response to a DATA error.4#5# Only one notification per ZED_NOTIFY_INTERVAL_SECS will be sent for a given6# class/pool/[vdev] combination. This protects against spamming the recipient7# should multiple events occur together in time for the same pool/[vdev].8#9# Exit codes:10# 0: notification sent11# 1: notification failed12# 2: notification not configured13# 3: notification suppressed14# 9: internal error1516[ -f "${ZED_ZEDLET_DIR}/zed.rc" ] && . "${ZED_ZEDLET_DIR}/zed.rc"17. "${ZED_ZEDLET_DIR}/zed-functions.sh"1819[ -n "${ZEVENT_POOL}" ] || exit 920[ -n "${ZEVENT_SUBCLASS}" ] || exit 921[ -n "${ZED_NOTIFY_DATA}" ] || exit 32223rate_limit_tag="${ZEVENT_POOL};${ZEVENT_VDEV_GUID:-0};${ZEVENT_SUBCLASS};notify"24zed_rate_limit "${rate_limit_tag}" || exit 32526umask 07727note_subject="ZFS ${ZEVENT_SUBCLASS} error for ${ZEVENT_POOL} on $(hostname)"28note_pathname="$(mktemp)"29{30echo "ZFS has detected a data error:"31echo32echo " eid: ${ZEVENT_EID}"33echo " class: ${ZEVENT_SUBCLASS}"34echo " host: $(hostname)"35echo " time: ${ZEVENT_TIME_STRING}"36echo " error: ${ZEVENT_ZIO_ERR}"37echo " objid: ${ZEVENT_ZIO_OBJSET}:${ZEVENT_ZIO_OBJECT}"38echo " pool: ${ZEVENT_POOL}"39} > "${note_pathname}"4041zed_notify "${note_subject}" "${note_pathname}"; rv=$?42rm -f "${note_pathname}"43exit "${rv}"444546