]> git.proxmox.com Git - mirror_zfs-debian.git/blame - cmd/zed/zed.d/data-notify.sh
New upstream version 0.7.2
[mirror_zfs-debian.git] / cmd / zed / zed.d / data-notify.sh
CommitLineData
e10b0808
AX
1#!/bin/sh
2#
cae5b340 3# Send notification in response to a DATA error.
e10b0808
AX
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
cae5b340 21[ -n "${ZED_NOTIFY_DATA}" ] || exit 3
e10b0808
AX
22
23rate_limit_tag="${ZEVENT_POOL};${ZEVENT_VDEV_GUID:-0};${ZEVENT_SUBCLASS};notify"
24zed_rate_limit "${rate_limit_tag}" || exit 3
25
26umask 077
27note_subject="ZFS ${ZEVENT_SUBCLASS} error for ${ZEVENT_POOL} on $(hostname)"
28note_pathname="${TMPDIR:="/tmp"}/$(basename -- "$0").${ZEVENT_EID}.$$"
29{
cae5b340 30 echo "ZFS has detected a data error:"
e10b0808
AX
31 echo
32 echo " eid: ${ZEVENT_EID}"
33 echo " class: ${ZEVENT_SUBCLASS}"
34 echo " host: $(hostname)"
35 echo " time: ${ZEVENT_TIME_STRING}"
cae5b340
AX
36 echo " error: ${ZEVENT_ZIO_ERR}"
37 echo " objid: ${ZEVENT_ZIO_OBJSET}:${ZEVENT_ZIO_OBJECT}"
e10b0808 38 echo " pool: ${ZEVENT_POOL}"
e10b0808
AX
39} > "${note_pathname}"
40
41zed_notify "${note_subject}" "${note_pathname}"; rv=$?
42rm -f "${note_pathname}"
43exit "${rv}"