1*eda14cbcSMatt Macy#!/bin/sh 2*eda14cbcSMatt Macy# 3*eda14cbcSMatt Macy# Send notification in response to a DATA error. 4*eda14cbcSMatt Macy# 5*eda14cbcSMatt Macy# Only one notification per ZED_NOTIFY_INTERVAL_SECS will be sent for a given 6*eda14cbcSMatt Macy# class/pool/[vdev] combination. This protects against spamming the recipient 7*eda14cbcSMatt Macy# should multiple events occur together in time for the same pool/[vdev]. 8*eda14cbcSMatt Macy# 9*eda14cbcSMatt Macy# Exit codes: 10*eda14cbcSMatt Macy# 0: notification sent 11*eda14cbcSMatt Macy# 1: notification failed 12*eda14cbcSMatt Macy# 2: notification not configured 13*eda14cbcSMatt Macy# 3: notification suppressed 14*eda14cbcSMatt Macy# 9: internal error 15*eda14cbcSMatt Macy 16*eda14cbcSMatt Macy[ -f "${ZED_ZEDLET_DIR}/zed.rc" ] && . "${ZED_ZEDLET_DIR}/zed.rc" 17*eda14cbcSMatt Macy. "${ZED_ZEDLET_DIR}/zed-functions.sh" 18*eda14cbcSMatt Macy 19*eda14cbcSMatt Macy[ -n "${ZEVENT_POOL}" ] || exit 9 20*eda14cbcSMatt Macy[ -n "${ZEVENT_SUBCLASS}" ] || exit 9 21*eda14cbcSMatt Macy[ -n "${ZED_NOTIFY_DATA}" ] || exit 3 22*eda14cbcSMatt Macy 23*eda14cbcSMatt Macyrate_limit_tag="${ZEVENT_POOL};${ZEVENT_VDEV_GUID:-0};${ZEVENT_SUBCLASS};notify" 24*eda14cbcSMatt Macyzed_rate_limit "${rate_limit_tag}" || exit 3 25*eda14cbcSMatt Macy 26*eda14cbcSMatt Macyumask 077 27*eda14cbcSMatt Macynote_subject="ZFS ${ZEVENT_SUBCLASS} error for ${ZEVENT_POOL} on $(hostname)" 28*eda14cbcSMatt Macynote_pathname="${TMPDIR:="/tmp"}/$(basename -- "$0").${ZEVENT_EID}.$$" 29*eda14cbcSMatt Macy{ 30*eda14cbcSMatt Macy echo "ZFS has detected a data error:" 31*eda14cbcSMatt Macy echo 32*eda14cbcSMatt Macy echo " eid: ${ZEVENT_EID}" 33*eda14cbcSMatt Macy echo " class: ${ZEVENT_SUBCLASS}" 34*eda14cbcSMatt Macy echo " host: $(hostname)" 35*eda14cbcSMatt Macy echo " time: ${ZEVENT_TIME_STRING}" 36*eda14cbcSMatt Macy echo " error: ${ZEVENT_ZIO_ERR}" 37*eda14cbcSMatt Macy echo " objid: ${ZEVENT_ZIO_OBJSET}:${ZEVENT_ZIO_OBJECT}" 38*eda14cbcSMatt Macy echo " pool: ${ZEVENT_POOL}" 39*eda14cbcSMatt Macy} > "${note_pathname}" 40*eda14cbcSMatt Macy 41*eda14cbcSMatt Macyzed_notify "${note_subject}" "${note_pathname}"; rv=$? 42*eda14cbcSMatt Macyrm -f "${note_pathname}" 43*eda14cbcSMatt Macyexit "${rv}" 44