The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/contrib/openzfs/cmd/zed/zed.d/scrub_finish-notify.sh

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 #!/bin/sh
    2 # shellcheck disable=SC2154
    3 #
    4 # Send notification in response to a RESILVER_FINISH or SCRUB_FINISH.
    5 #
    6 # By default, "zpool status" output will only be included for a scrub_finish
    7 # zevent if the pool is not healthy; to always include its output, set
    8 # ZED_NOTIFY_VERBOSE=1.
    9 #
   10 # Exit codes:
   11 #   0: notification sent
   12 #   1: notification failed
   13 #   2: notification not configured
   14 #   3: notification suppressed
   15 #   9: internal error
   16 
   17 [ -f "${ZED_ZEDLET_DIR}/zed.rc" ] && . "${ZED_ZEDLET_DIR}/zed.rc"
   18 . "${ZED_ZEDLET_DIR}/zed-functions.sh"
   19 
   20 [ -n "${ZEVENT_POOL}" ] || exit 9
   21 [ -n "${ZEVENT_SUBCLASS}" ] || exit 9
   22 
   23 if   [ "${ZEVENT_SUBCLASS}" = "resilver_finish" ]; then
   24     action="resilver"
   25 elif [ "${ZEVENT_SUBCLASS}" = "scrub_finish" ]; then
   26     action="scrub"
   27 else
   28     zed_log_err "unsupported event class \"${ZEVENT_SUBCLASS}\""
   29     exit 9
   30 fi
   31 
   32 zed_check_cmd "${ZPOOL}" || exit 9
   33 
   34 # For scrub, suppress notification if the pool is healthy
   35 # and verbosity is not enabled.
   36 #
   37 if [ "${ZEVENT_SUBCLASS}" = "scrub_finish" ]; then
   38     healthy="$("${ZPOOL}" status -x "${ZEVENT_POOL}" \
   39         | grep "'${ZEVENT_POOL}' is healthy")"
   40     [ -n "${healthy}" ] && [ "${ZED_NOTIFY_VERBOSE}" -eq 0 ] && exit 3
   41 fi
   42 
   43 umask 077
   44 note_subject="ZFS ${ZEVENT_SUBCLASS} event for ${ZEVENT_POOL} on $(hostname)"
   45 note_pathname="$(mktemp)"
   46 {
   47     echo "ZFS has finished a ${action}:"
   48     echo
   49     echo "   eid: ${ZEVENT_EID}"
   50     echo " class: ${ZEVENT_SUBCLASS}"
   51     echo "  host: $(hostname)"
   52     echo "  time: ${ZEVENT_TIME_STRING}"
   53 
   54     "${ZPOOL}" status "${ZEVENT_POOL}"
   55 
   56 } > "${note_pathname}"
   57 
   58 zed_notify "${note_subject}" "${note_pathname}"; rv=$?
   59 rm -f "${note_pathname}"
   60 exit "${rv}"

Cache object: adc13a4f6ff2c57dab305fbab120088e


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.