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