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/statechange-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 # CDDL HEADER START
    5 #
    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.
   11 #
   12 # CDDL HEADER END
   13 #
   14 
   15 #
   16 # Send notification in response to a fault induced statechange
   17 #
   18 # ZEVENT_SUBCLASS: 'statechange'
   19 # ZEVENT_VDEV_STATE_STR: 'DEGRADED', 'FAULTED', 'REMOVED', or 'UNAVAIL'
   20 #
   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)
   27 
   28 [ -f "${ZED_ZEDLET_DIR}/zed.rc" ] && . "${ZED_ZEDLET_DIR}/zed.rc"
   29 . "${ZED_ZEDLET_DIR}/zed-functions.sh"
   30 
   31 [ -n "${ZEVENT_VDEV_STATE_STR}" ] || exit 4
   32 
   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
   38 fi
   39 
   40 umask 077
   41 note_subject="ZFS device fault for pool ${ZEVENT_POOL} on $(hostname)"
   42 note_pathname="$(mktemp)"
   43 {
   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."
   53     fi
   54 
   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}"
   62 
   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}"
   68 
   69     echo "   pool: ${ZEVENT_POOL} (${ZEVENT_POOL_GUID})"
   70 
   71 } > "${note_pathname}"
   72 
   73 zed_notify "${note_subject}" "${note_pathname}"; rv=$?
   74 
   75 rm -f "${note_pathname}"
   76 exit "${rv}"

Cache object: 0b9e9adc3b20c8a63adf5b2fc3dccab4


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