Path: blob/main/sys/contrib/openzfs/cmd/zed/zed.d/all-syslog.sh
48529 views
#!/bin/sh1# shellcheck disable=SC21542#3# Copyright (C) 2013-2014 Lawrence Livermore National Security, LLC.4# Copyright (c) 2020 by Delphix. All rights reserved.5#67#8# Log the zevent via syslog.9#1011[ -f "${ZED_ZEDLET_DIR}/zed.rc" ] && . "${ZED_ZEDLET_DIR}/zed.rc"12. "${ZED_ZEDLET_DIR}/zed-functions.sh"1314zed_exit_if_ignoring_this_event1516# build a string of name=value pairs for this event17msg="eid=${ZEVENT_EID} class=${ZEVENT_SUBCLASS}"1819if [ "${ZED_SYSLOG_DISPLAY_GUIDS}" = "1" ]; then20[ -n "${ZEVENT_POOL_GUID}" ] && msg="${msg} pool_guid=${ZEVENT_POOL_GUID}"21[ -n "${ZEVENT_VDEV_GUID}" ] && msg="${msg} vdev_guid=${ZEVENT_VDEV_GUID}"22else23[ -n "${ZEVENT_POOL}" ] && msg="${msg} pool='${ZEVENT_POOL}'"24[ -n "${ZEVENT_VDEV_PATH}" ] && msg="${msg} vdev=${ZEVENT_VDEV_PATH##*/}"25fi2627# log pool state if state is anything other than 'ACTIVE'28[ -n "${ZEVENT_POOL_STATE_STR}" ] && [ "$ZEVENT_POOL_STATE" -ne 0 ] && \29msg="${msg} pool_state=${ZEVENT_POOL_STATE_STR}"3031# Log the following payload nvpairs if they are present32[ -n "${ZEVENT_VDEV_STATE_STR}" ] && msg="${msg} vdev_state=${ZEVENT_VDEV_STATE_STR}"33[ -n "${ZEVENT_CKSUM_ALGORITHM}" ] && msg="${msg} algorithm=${ZEVENT_CKSUM_ALGORITHM}"34[ -n "${ZEVENT_ZIO_SIZE}" ] && msg="${msg} size=${ZEVENT_ZIO_SIZE}"35[ -n "${ZEVENT_ZIO_OFFSET}" ] && msg="${msg} offset=${ZEVENT_ZIO_OFFSET}"36[ -n "${ZEVENT_ZIO_PRIORITY}" ] && msg="${msg} priority=${ZEVENT_ZIO_PRIORITY}"37[ -n "${ZEVENT_ZIO_ERR}" ] && msg="${msg} err=${ZEVENT_ZIO_ERR}"38[ -n "${ZEVENT_ZIO_FLAGS}" ] && msg="${msg} flags=$(printf '0x%x' "${ZEVENT_ZIO_FLAGS}")"3940# log delays that are >= 10 milisec41[ -n "${ZEVENT_ZIO_DELAY}" ] && [ "$ZEVENT_ZIO_DELAY" -gt 10000000 ] && \42msg="${msg} delay=$((ZEVENT_ZIO_DELAY / 1000000))ms"4344# list the bookmark data together45# shellcheck disable=SC215346[ -n "${ZEVENT_ZIO_OBJSET}" ] && \47msg="${msg} bookmark=${ZEVENT_ZIO_OBJSET}:${ZEVENT_ZIO_OBJECT}:${ZEVENT_ZIO_LEVEL}:${ZEVENT_ZIO_BLKID}"4849zed_log_msg "${msg}"5051exit 0525354