Path: blob/main/sys/contrib/openzfs/cmd/zed/zed.d/trim_finish-notify.sh
48529 views
#!/bin/sh1# shellcheck disable=SC21542#3# Send notification in response to a TRIM_FINISH. The event4# will be received for each vdev in the pool which was trimmed.5#6# Exit codes:7# 0: notification sent8# 1: notification failed9# 2: notification not configured10# 9: internal error1112[ -f "${ZED_ZEDLET_DIR}/zed.rc" ] && . "${ZED_ZEDLET_DIR}/zed.rc"13. "${ZED_ZEDLET_DIR}/zed-functions.sh"1415[ -n "${ZEVENT_POOL}" ] || exit 916[ -n "${ZEVENT_SUBCLASS}" ] || exit 91718zed_check_cmd "${ZPOOL}" || exit 91920umask 07721note_subject="ZFS ${ZEVENT_SUBCLASS} event for ${ZEVENT_POOL} on $(hostname)"22note_pathname="$(mktemp)"23{24echo "ZFS has finished a trim:"25echo26echo " eid: ${ZEVENT_EID}"27echo " class: ${ZEVENT_SUBCLASS}"28echo " host: $(hostname)"29echo " time: ${ZEVENT_TIME_STRING}"3031"${ZPOOL}" status -t "${ZEVENT_POOL}"3233} > "${note_pathname}"3435zed_notify "${note_subject}" "${note_pathname}"; rv=$?36rm -f "${note_pathname}"37exit "${rv}"383940