1#!/bin/sh 2# shellcheck disable=SC2154 3# 4# Copyright (C) 2013-2014 Lawrence Livermore National Security, LLC. 5# Copyright (c) 2020 by Delphix. All rights reserved. 6# 7 8# 9# Log the zevent via syslog. 10# 11 12[ -f "${ZED_ZEDLET_DIR}/zed.rc" ] && . "${ZED_ZEDLET_DIR}/zed.rc" 13. "${ZED_ZEDLET_DIR}/zed-functions.sh" 14 15zed_exit_if_ignoring_this_event 16 17# build a string of name=value pairs for this event 18msg="eid=${ZEVENT_EID} class=${ZEVENT_SUBCLASS}" 19 20if [ "${ZED_SYSLOG_DISPLAY_GUIDS}" = "1" ]; then 21 [ -n "${ZEVENT_POOL_GUID}" ] && msg="${msg} pool_guid=${ZEVENT_POOL_GUID}" 22 [ -n "${ZEVENT_VDEV_GUID}" ] && msg="${msg} vdev_guid=${ZEVENT_VDEV_GUID}" 23else 24 [ -n "${ZEVENT_POOL}" ] && msg="${msg} pool='${ZEVENT_POOL}'" 25 [ -n "${ZEVENT_VDEV_PATH}" ] && msg="${msg} vdev=${ZEVENT_VDEV_PATH##*/}" 26fi 27 28# log pool state if state is anything other than 'ACTIVE' 29[ -n "${ZEVENT_POOL_STATE_STR}" ] && [ "$ZEVENT_POOL_STATE" -ne 0 ] && \ 30 msg="${msg} pool_state=${ZEVENT_POOL_STATE_STR}" 31 32# Log the following payload nvpairs if they are present 33[ -n "${ZEVENT_VDEV_STATE_STR}" ] && msg="${msg} vdev_state=${ZEVENT_VDEV_STATE_STR}" 34[ -n "${ZEVENT_CKSUM_ALGORITHM}" ] && msg="${msg} algorithm=${ZEVENT_CKSUM_ALGORITHM}" 35[ -n "${ZEVENT_ZIO_SIZE}" ] && msg="${msg} size=${ZEVENT_ZIO_SIZE}" 36[ -n "${ZEVENT_ZIO_OFFSET}" ] && msg="${msg} offset=${ZEVENT_ZIO_OFFSET}" 37[ -n "${ZEVENT_ZIO_PRIORITY}" ] && msg="${msg} priority=${ZEVENT_ZIO_PRIORITY}" 38[ -n "${ZEVENT_ZIO_ERR}" ] && msg="${msg} err=${ZEVENT_ZIO_ERR}" 39[ -n "${ZEVENT_ZIO_FLAGS}" ] && msg="${msg} flags=$(printf '0x%x' "${ZEVENT_ZIO_FLAGS}")" 40 41# log delays that are >= 10 milisec 42[ -n "${ZEVENT_ZIO_DELAY}" ] && [ "$ZEVENT_ZIO_DELAY" -gt 10000000 ] && \ 43 msg="${msg} delay=$((ZEVENT_ZIO_DELAY / 1000000))ms" 44 45# list the bookmark data together 46# shellcheck disable=SC2153 47[ -n "${ZEVENT_ZIO_OBJSET}" ] && \ 48 msg="${msg} bookmark=${ZEVENT_ZIO_OBJSET}:${ZEVENT_ZIO_OBJECT}:${ZEVENT_ZIO_LEVEL}:${ZEVENT_ZIO_BLKID}" 49 50zed_log_msg "${msg}" 51 52exit 0 53