xref: /freebsd/sys/contrib/openzfs/cmd/zed/zed.d/all-syslog.sh (revision e92ffd9b626833ebdbf2742c8ffddc6cd94b963e)
1eda14cbcSMatt Macy#!/bin/sh
2*e92ffd9bSMartin Matuska# shellcheck disable=SC2154
3eda14cbcSMatt Macy#
47877fdebSMatt Macy# Copyright (C) 2013-2014 Lawrence Livermore National Security, LLC.
57877fdebSMatt Macy# Copyright (c) 2020 by Delphix. All rights reserved.
67877fdebSMatt Macy#
77877fdebSMatt Macy
87877fdebSMatt Macy#
9eda14cbcSMatt Macy# Log the zevent via syslog.
107877fdebSMatt Macy#
11eda14cbcSMatt Macy
12eda14cbcSMatt Macy[ -f "${ZED_ZEDLET_DIR}/zed.rc" ] && . "${ZED_ZEDLET_DIR}/zed.rc"
13eda14cbcSMatt Macy. "${ZED_ZEDLET_DIR}/zed-functions.sh"
14eda14cbcSMatt Macy
15eda14cbcSMatt Macyzed_exit_if_ignoring_this_event
16eda14cbcSMatt Macy
177877fdebSMatt Macy# build a string of name=value pairs for this event
187877fdebSMatt Macymsg="eid=${ZEVENT_EID} class=${ZEVENT_SUBCLASS}"
197877fdebSMatt Macy
207877fdebSMatt Macyif [ "${ZED_SYSLOG_DISPLAY_GUIDS}" = "1" ]; then
217877fdebSMatt Macy    [ -n "${ZEVENT_POOL_GUID}" ] && msg="${msg} pool_guid=${ZEVENT_POOL_GUID}"
227877fdebSMatt Macy    [ -n "${ZEVENT_VDEV_GUID}" ] && msg="${msg} vdev_guid=${ZEVENT_VDEV_GUID}"
237877fdebSMatt Macyelse
247877fdebSMatt Macy    [ -n "${ZEVENT_POOL}" ] && msg="${msg} pool='${ZEVENT_POOL}'"
25dae17134SMartin Matuska    [ -n "${ZEVENT_VDEV_PATH}" ] && msg="${msg} vdev=${ZEVENT_VDEV_PATH##*/}"
267877fdebSMatt Macyfi
277877fdebSMatt Macy
287877fdebSMatt Macy# log pool state if state is anything other than 'ACTIVE'
297877fdebSMatt Macy[ -n "${ZEVENT_POOL_STATE_STR}" ] && [ "$ZEVENT_POOL_STATE" -ne 0 ] && \
307877fdebSMatt Macy    msg="${msg} pool_state=${ZEVENT_POOL_STATE_STR}"
317877fdebSMatt Macy
327877fdebSMatt Macy# Log the following payload nvpairs if they are present
337877fdebSMatt Macy[ -n "${ZEVENT_VDEV_STATE_STR}" ]  && msg="${msg} vdev_state=${ZEVENT_VDEV_STATE_STR}"
347877fdebSMatt Macy[ -n "${ZEVENT_CKSUM_ALGORITHM}" ] && msg="${msg} algorithm=${ZEVENT_CKSUM_ALGORITHM}"
357877fdebSMatt Macy[ -n "${ZEVENT_ZIO_SIZE}" ]        && msg="${msg} size=${ZEVENT_ZIO_SIZE}"
367877fdebSMatt Macy[ -n "${ZEVENT_ZIO_OFFSET}" ]      && msg="${msg} offset=${ZEVENT_ZIO_OFFSET}"
377877fdebSMatt Macy[ -n "${ZEVENT_ZIO_PRIORITY}" ]    && msg="${msg} priority=${ZEVENT_ZIO_PRIORITY}"
387877fdebSMatt Macy[ -n "${ZEVENT_ZIO_ERR}" ]         && msg="${msg} err=${ZEVENT_ZIO_ERR}"
397877fdebSMatt Macy[ -n "${ZEVENT_ZIO_FLAGS}" ]       && msg="${msg} flags=$(printf '0x%x' "${ZEVENT_ZIO_FLAGS}")"
407877fdebSMatt Macy
417877fdebSMatt Macy# log delays that are >= 10 milisec
427877fdebSMatt Macy[ -n "${ZEVENT_ZIO_DELAY}" ] && [ "$ZEVENT_ZIO_DELAY" -gt 10000000 ] && \
437877fdebSMatt Macy    msg="${msg} delay=$((ZEVENT_ZIO_DELAY / 1000000))ms"
447877fdebSMatt Macy
457877fdebSMatt Macy# list the bookmark data together
463ff01b23SMartin Matuska# shellcheck disable=SC2153
477877fdebSMatt Macy[ -n "${ZEVENT_ZIO_OBJSET}" ] && \
487877fdebSMatt Macy    msg="${msg} bookmark=${ZEVENT_ZIO_OBJSET}:${ZEVENT_ZIO_OBJECT}:${ZEVENT_ZIO_LEVEL}:${ZEVENT_ZIO_BLKID}"
497877fdebSMatt Macy
507877fdebSMatt Macyzed_log_msg "${msg}"
517877fdebSMatt Macy
52eda14cbcSMatt Macyexit 0
53