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/generic-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 given zevent.
    5 #
    6 # This is a generic script than can be symlinked to a file in the
    7 # enabled-zedlets directory to have a notification sent when a particular
    8 # class of zevents occurs.  The symlink filename must begin with the zevent
    9 # (sub)class string (e.g., "probe_failure-notify.sh" for the "probe_failure"
   10 # subclass).  Refer to the zed(8) manpage for details.
   11 #
   12 # Only one notification per ZED_NOTIFY_INTERVAL_SECS will be sent for a given
   13 # class/pool combination.  This protects against spamming the recipient
   14 # should multiple events occur together in time for the same pool.
   15 #
   16 # Exit codes:
   17 #   0: notification sent
   18 #   1: notification failed
   19 #   2: notification not configured
   20 #   3: notification suppressed
   21 
   22 [ -f "${ZED_ZEDLET_DIR}/zed.rc" ] && . "${ZED_ZEDLET_DIR}/zed.rc"
   23 . "${ZED_ZEDLET_DIR}/zed-functions.sh"
   24 
   25 # Rate-limit the notification based in part on the filename.
   26 #
   27 rate_limit_tag="${ZEVENT_POOL};${ZEVENT_SUBCLASS};${0##*/}"
   28 rate_limit_interval="${ZED_NOTIFY_INTERVAL_SECS}"
   29 zed_rate_limit "${rate_limit_tag}" "${rate_limit_interval}" || exit 3
   30 
   31 umask 077
   32 pool_str="${ZEVENT_POOL:+" for ${ZEVENT_POOL}"}"
   33 host_str=" on $(hostname)"
   34 note_subject="ZFS ${ZEVENT_SUBCLASS} event${pool_str}${host_str}"
   35 note_pathname="$(mktemp)"
   36 {
   37     echo "ZFS has posted the following event:"
   38     echo
   39     echo "   eid: ${ZEVENT_EID}"
   40     echo " class: ${ZEVENT_SUBCLASS}"
   41     echo "  host: $(hostname)"
   42     echo "  time: ${ZEVENT_TIME_STRING}"
   43 
   44     [ -n "${ZEVENT_VDEV_TYPE}" ] && echo " vtype: ${ZEVENT_VDEV_TYPE}"
   45     [ -n "${ZEVENT_VDEV_PATH}" ] && echo " vpath: ${ZEVENT_VDEV_PATH}"
   46     [ -n "${ZEVENT_VDEV_GUID}" ] && echo " vguid: ${ZEVENT_VDEV_GUID}"
   47 
   48     [ -n "${ZEVENT_POOL}" ] && [ -x "${ZPOOL}" ] \
   49         && "${ZPOOL}" status "${ZEVENT_POOL}"
   50 
   51 } > "${note_pathname}"
   52 
   53 zed_notify "${note_subject}" "${note_pathname}"; rv=$?
   54 rm -f "${note_pathname}"
   55 exit "${rv}"

Cache object: 30e3839b6dc36aee7f5d1470ac59de1c


[ 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.