ARC: Cache arc_c value during arc_evict()
[zfs.git] / cmd / zed / zed.d / statechange-notify.sh
blobae610df20e459c1dab888f20d48088cf8634adef
1 #!/bin/sh
2 # shellcheck disable=SC2154
4 # CDDL HEADER START
6 # The contents of this file are subject to the terms of the
7 # Common Development and Distribution License Version 1.0 (CDDL-1.0).
8 # You can obtain a copy of the license from the top-level file
9 # "OPENSOLARIS.LICENSE" or at <http://opensource.org/licenses/CDDL-1.0>.
10 # You may not use this file except in compliance with the license.
12 # CDDL HEADER END
16 # Send notification in response to a fault induced statechange
18 # ZEVENT_SUBCLASS: 'statechange'
19 # ZEVENT_VDEV_STATE_STR: 'DEGRADED', 'FAULTED', 'REMOVED', or 'UNAVAIL'
21 # Exit codes:
22 # 0: notification sent
23 # 1: notification failed
24 # 2: notification not configured
25 # 3: statechange not relevant
26 # 4: statechange string missing (unexpected)
28 [ -f "${ZED_ZEDLET_DIR}/zed.rc" ] && . "${ZED_ZEDLET_DIR}/zed.rc"
29 . "${ZED_ZEDLET_DIR}/zed-functions.sh"
31 [ -n "${ZEVENT_VDEV_STATE_STR}" ] || exit 4
33 if [ "${ZEVENT_VDEV_STATE_STR}" != "FAULTED" ] \
34 && [ "${ZEVENT_VDEV_STATE_STR}" != "DEGRADED" ] \
35 && [ "${ZEVENT_VDEV_STATE_STR}" != "REMOVED" ] \
36 && [ "${ZEVENT_VDEV_STATE_STR}" != "UNAVAIL" ]; then
37 exit 3
40 umask 077
41 note_subject="ZFS device fault for pool ${ZEVENT_POOL} on $(hostname)"
42 note_pathname="$(mktemp)"
44 if [ "${ZEVENT_VDEV_STATE_STR}" = "FAULTED" ] ; then
45 echo "The number of I/O errors associated with a ZFS device exceeded"
46 echo "acceptable levels. ZFS has marked the device as faulted."
47 elif [ "${ZEVENT_VDEV_STATE_STR}" = "DEGRADED" ] ; then
48 echo "The number of checksum errors associated with a ZFS device"
49 echo "exceeded acceptable levels. ZFS has marked the device as"
50 echo "degraded."
51 else
52 echo "ZFS has detected that a device was removed."
55 echo
56 echo " impact: Fault tolerance of the pool may be compromised."
57 echo " eid: ${ZEVENT_EID}"
58 echo " class: ${ZEVENT_SUBCLASS}"
59 echo " state: ${ZEVENT_VDEV_STATE_STR}"
60 echo " host: $(hostname)"
61 echo " time: ${ZEVENT_TIME_STRING}"
63 [ -n "${ZEVENT_VDEV_TYPE}" ] && echo " vtype: ${ZEVENT_VDEV_TYPE}"
64 [ -n "${ZEVENT_VDEV_PATH}" ] && echo " vpath: ${ZEVENT_VDEV_PATH}"
65 [ -n "${ZEVENT_VDEV_PHYSPATH}" ] && echo " vphys: ${ZEVENT_VDEV_PHYSPATH}"
66 [ -n "${ZEVENT_VDEV_GUID}" ] && echo " vguid: ${ZEVENT_VDEV_GUID}"
67 [ -n "${ZEVENT_VDEV_DEVID}" ] && echo " devid: ${ZEVENT_VDEV_DEVID}"
69 echo " pool: ${ZEVENT_POOL} (${ZEVENT_POOL_GUID})"
71 } > "${note_pathname}"
73 zed_notify "${note_subject}" "${note_pathname}"; rv=$?
75 rm -f "${note_pathname}"
76 exit "${rv}"