1eda14cbcSMatt Macy.\" 2180f8225SMatt Macy.\" This file is part of the ZFS Event Daemon (ZED). 3eda14cbcSMatt Macy.\" Developed at Lawrence Livermore National Laboratory (LLNL-CODE-403049). 4eda14cbcSMatt Macy.\" Copyright (C) 2013-2014 Lawrence Livermore National Security, LLC. 516038816SMartin Matuska.\" Refer to the OpenZFS git commit log for authoritative copyright attribution. 6eda14cbcSMatt Macy.\" 7eda14cbcSMatt Macy.\" The contents of this file are subject to the terms of the 8eda14cbcSMatt Macy.\" Common Development and Distribution License Version 1.0 (CDDL-1.0). 9eda14cbcSMatt Macy.\" You can obtain a copy of the license from the top-level file 10eda14cbcSMatt Macy.\" "OPENSOLARIS.LICENSE" or at <http://opensource.org/licenses/CDDL-1.0>. 11eda14cbcSMatt Macy.\" You may not use this file except in compliance with the license. 12eda14cbcSMatt Macy.\" 1316038816SMartin Matuska.\" Developed at Lawrence Livermore National Laboratory (LLNL-CODE-403049) 1416038816SMartin Matuska.\" 1516038816SMartin Matuska.Dd May 26, 2021 1616038816SMartin Matuska.Dt ZED 8 1716038816SMartin Matuska.Os 1816038816SMartin Matuska. 1916038816SMartin Matuska.Sh NAME 2016038816SMartin Matuska.Nm ZED 2116038816SMartin Matuska.Nd ZFS Event Daemon 2216038816SMartin Matuska.Sh SYNOPSIS 2316038816SMartin Matuska.Nm 2416038816SMartin Matuska.Op Fl fFhILMvVZ 2516038816SMartin Matuska.Op Fl d Ar zedletdir 2616038816SMartin Matuska.Op Fl p Ar pidfile 2716038816SMartin Matuska.Op Fl P Ar path 2816038816SMartin Matuska.Op Fl s Ar statefile 2916038816SMartin Matuska.Op Fl j Ar jobs 3016038816SMartin Matuska. 3116038816SMartin Matuska.Sh DESCRIPTION 3216038816SMartin MatuskaThe 3316038816SMartin Matuska.Nm 3416038816SMartin Matuska(ZFS Event Daemon) monitors events generated by the ZFS kernel 3516038816SMartin Matuskamodule. 3616038816SMartin MatuskaWhen a zevent (ZFS Event) is posted, the 3716038816SMartin Matuska.Nm 3816038816SMartin Matuskawill run any ZEDLETs (ZFS Event Daemon Linkage for Executable Tasks) 3916038816SMartin Matuskathat have been enabled for the corresponding zevent class. 4016038816SMartin Matuska. 4116038816SMartin Matuska.Sh OPTIONS 4216038816SMartin Matuska.Bl -tag -width "-h" 4316038816SMartin Matuska.It Fl h 44eda14cbcSMatt MacyDisplay a summary of the command-line options. 4516038816SMartin Matuska.It Fl L 46eda14cbcSMatt MacyDisplay license information. 4716038816SMartin Matuska.It Fl V 48eda14cbcSMatt MacyDisplay version information. 4916038816SMartin Matuska.It Fl v 50eda14cbcSMatt MacyBe verbose. 5116038816SMartin Matuska.It Fl f 52eda14cbcSMatt MacyForce the daemon to run if at all possible, disabling security checks and 5316038816SMartin Matuskathrowing caution to the wind. 5416038816SMartin MatuskaNot recommended for use in production. 5516038816SMartin Matuska.It Fl F 5616038816SMartin MatuskaDon't daemonise: remain attached to the controlling terminal, 5716038816SMartin Matuskalog to the standard I/O streams. 5816038816SMartin Matuska.It Fl M 59eda14cbcSMatt MacyLock all current and future pages in the virtual memory address space. 60eda14cbcSMatt MacyThis may help the daemon remain responsive when the system is under heavy 61eda14cbcSMatt Macymemory pressure. 6216038816SMartin Matuska.It Fl I 6316038816SMartin MatuskaRequest that the daemon idle rather than exit when the kernel modules are not loaded. 6416038816SMartin MatuskaProcessing of events will start, or resume, when the kernel modules are (re)loaded. 6516038816SMartin MatuskaUnder Linux the kernel modules cannot be unloaded while the daemon is running. 6616038816SMartin Matuska.It Fl Z 67eda14cbcSMatt MacyZero the daemon's state, thereby allowing zevents still within the kernel 68eda14cbcSMatt Macyto be reprocessed. 6916038816SMartin Matuska.It Fl d Ar zedletdir 70eda14cbcSMatt MacyRead the enabled ZEDLETs from the specified directory. 7116038816SMartin Matuska.It Fl p Ar pidfile 72eda14cbcSMatt MacyWrite the daemon's process ID to the specified file. 7316038816SMartin Matuska.It Fl P Ar path 7416038816SMartin MatuskaCustom 7516038816SMartin Matuska.Ev $PATH 7616038816SMartin Matuskafor zedlets to use. 7716038816SMartin MatuskaNormally zedlets run in a locked-down environment, with hardcoded paths to the ZFS commands 78*716fd348SMartin Matuska.Pq Ev $ZFS , $ZPOOL , $ZED , … , 7916038816SMartin Matuskaand a hard-coded 8016038816SMartin Matuska.Ev $PATH . 8116038816SMartin MatuskaThis is done for security reasons. 8216038816SMartin MatuskaHowever, the ZFS test suite uses a custom PATH for its ZFS commands, and passes it to 8316038816SMartin Matuska.Nm 8416038816SMartin Matuskawith 8516038816SMartin Matuska.Fl P . 8616038816SMartin MatuskaIn short, 8716038816SMartin Matuska.Fl P 8816038816SMartin Matuskais only to be used by the ZFS test suite; never use 89eda14cbcSMatt Macyit in production! 9016038816SMartin Matuska.It Fl s Ar statefile 91eda14cbcSMatt MacyWrite the daemon's state to the specified file. 9216038816SMartin Matuska.It Fl j Ar jobs 9316038816SMartin MatuskaAllow at most 9416038816SMartin Matuska.Ar jobs 9516038816SMartin MatuskaZEDLETs to run concurrently, 9616038816SMartin Matuskadelaying execution of new ones until they finish. 9716038816SMartin MatuskaDefaults to 9816038816SMartin Matuska.Sy 16 . 9916038816SMartin Matuska.El 10016038816SMartin Matuska.Sh ZEVENTS 10116038816SMartin MatuskaA zevent is comprised of a list of nvpairs (name/value pairs). 10216038816SMartin MatuskaEach zevent contains an EID (Event IDentifier) that uniquely identifies it throughout 103eda14cbcSMatt Macythe lifetime of the loaded ZFS kernel module; this EID is a monotonically 104eda14cbcSMatt Macyincreasing integer that resets to 1 each time the kernel module is loaded. 105eda14cbcSMatt MacyEach zevent also contains a class string that identifies the type of event. 106eda14cbcSMatt MacyFor brevity, a subclass string is defined that omits the leading components 10716038816SMartin Matuskaof the class string. 10816038816SMartin MatuskaAdditional nvpairs exist to provide event details. 10916038816SMartin Matuska.Pp 110eda14cbcSMatt MacyThe kernel maintains a list of recent zevents that can be viewed (along with 11116038816SMartin Matuskatheir associated lists of nvpairs) using the 11216038816SMartin Matuska.Nm zpool Cm events Fl v 11316038816SMartin Matuskacommand. 11416038816SMartin Matuska. 11516038816SMartin Matuska.Sh CONFIGURATION 116eda14cbcSMatt MacyZEDLETs to be invoked in response to zevents are located in the 11716038816SMartin Matuska.Em enabled-zedlets 11816038816SMartin Matuskadirectory 11916038816SMartin Matuska.Pq Ar zedletdir . 12016038816SMartin MatuskaThese can be symlinked or copied from the 12116038816SMartin Matuska.Em installed-zedlets 12216038816SMartin Matuskadirectory; symlinks allow for automatic updates 123eda14cbcSMatt Macyfrom the installed ZEDLETs, whereas copies preserve local modifications. 12416038816SMartin MatuskaAs a security measure, since ownership change is a privileged operation, 12516038816SMartin MatuskaZEDLETs must be owned by root. 12616038816SMartin MatuskaThey must have execute permissions for the user, 12716038816SMartin Matuskabut they must not have write permissions for group or other. 12816038816SMartin MatuskaDotfiles are ignored. 12916038816SMartin Matuska.Pp 130eda14cbcSMatt MacyZEDLETs are named after the zevent class for which they should be invoked. 131eda14cbcSMatt MacyIn particular, a ZEDLET will be invoked for a given zevent if either its 132eda14cbcSMatt Macyclass or subclass string is a prefix of its filename (and is followed by 13316038816SMartin Matuskaa non-alphabetic character). 13416038816SMartin MatuskaAs a special case, the prefix 13516038816SMartin Matuska.Sy all 13616038816SMartin Matuskamatches all zevents. 13716038816SMartin MatuskaMultiple ZEDLETs may be invoked for a given zevent. 13816038816SMartin Matuska. 13916038816SMartin Matuska.Sh ZEDLETS 140eda14cbcSMatt MacyZEDLETs are executables invoked by the ZED in response to a given zevent. 141eda14cbcSMatt MacyThey should be written under the presumption they can be invoked concurrently, 142eda14cbcSMatt Macyand they should use appropriate locking to access any shared resources. 143eda14cbcSMatt MacyCommon variables used by ZEDLETs can be stored in the default rc file which 14416038816SMartin Matuskais sourced by scripts; these variables should be prefixed with 14516038816SMartin Matuska.Sy ZED_ . 14616038816SMartin Matuska.Pp 147eda14cbcSMatt MacyThe zevent nvpairs are passed to ZEDLETs as environment variables. 148eda14cbcSMatt MacyEach nvpair name is converted to an environment variable in the following 14916038816SMartin Matuskamanner: 1503ff01b23SMartin Matuska.Bl -enum -compact 15116038816SMartin Matuska.It 15216038816SMartin Matuskait is prefixed with 15316038816SMartin Matuska.Sy ZEVENT_ , 15416038816SMartin Matuska.It 15516038816SMartin Matuskait is converted to uppercase, and 15616038816SMartin Matuska.It 15716038816SMartin Matuskaeach non-alphanumeric character is converted to an underscore. 15816038816SMartin Matuska.El 15916038816SMartin Matuska.Pp 160eda14cbcSMatt MacySome additional environment variables have been defined to present certain 16116038816SMartin Matuskanvpair values in a more convenient form. 16216038816SMartin MatuskaAn incomplete list of zevent environment variables is as follows: 1633ff01b23SMartin Matuska.Bl -tag -compact -width "ZEVENT_TIME_STRING" 16416038816SMartin Matuska.It Sy ZEVENT_EID 165eda14cbcSMatt MacyThe Event IDentifier. 16616038816SMartin Matuska.It Sy ZEVENT_CLASS 167eda14cbcSMatt MacyThe zevent class string. 16816038816SMartin Matuska.It Sy ZEVENT_SUBCLASS 169eda14cbcSMatt MacyThe zevent subclass string. 17016038816SMartin Matuska.It Sy ZEVENT_TIME 171eda14cbcSMatt MacyThe time at which the zevent was posted as 17216038816SMartin Matuska.Dq Em seconds nanoseconds 17316038816SMartin Matuskasince the Epoch. 17416038816SMartin Matuska.It Sy ZEVENT_TIME_SECS 17516038816SMartin MatuskaThe 17616038816SMartin Matuska.Em seconds 17716038816SMartin Matuskacomponent of 17816038816SMartin Matuska.Sy ZEVENT_TIME . 17916038816SMartin Matuska.It Sy ZEVENT_TIME_NSECS 18016038816SMartin MatuskaThe 18116038816SMartin Matuska.Em nanoseconds 18216038816SMartin Matuskacomponent of 18316038816SMartin Matuska.Sy ZEVENT_TIME . 18416038816SMartin Matuska.It Sy ZEVENT_TIME_STRING 18516038816SMartin MatuskaAn almost-RFC3339-compliant string for 18616038816SMartin Matuska.Sy ZEVENT_TIME . 18716038816SMartin Matuska.El 18816038816SMartin Matuska.Pp 189eda14cbcSMatt MacyAdditionally, the following ZED & ZFS variables are defined: 1903ff01b23SMartin Matuska.Bl -tag -compact -width "ZEVENT_TIME_STRING" 19116038816SMartin Matuska.It Sy ZED_PID 192eda14cbcSMatt MacyThe daemon's process ID. 19316038816SMartin Matuska.It Sy ZED_ZEDLET_DIR 19416038816SMartin MatuskaThe daemon's current 19516038816SMartin Matuska.Em enabled-zedlets 19616038816SMartin Matuskadirectory. 19716038816SMartin Matuska.It Sy ZFS_ALIAS 19816038816SMartin MatuskaThe alias 19916038816SMartin Matuska.Pq Dq Em name Ns - Ns Em version Ns - Ns Em release 20016038816SMartin Matuskastring of the ZFS distribution the daemon is part of. 20116038816SMartin Matuska.It Sy ZFS_VERSION 20216038816SMartin MatuskaThe ZFS version the daemon is part of. 20316038816SMartin Matuska.It Sy ZFS_RELEASE 20416038816SMartin MatuskaThe ZFS release the daemon is part of. 20516038816SMartin Matuska.El 20616038816SMartin Matuska.Pp 20716038816SMartin MatuskaZEDLETs may need to call other ZFS commands. 20816038816SMartin MatuskaThe installation paths of the following executables are defined as environment variables: 20916038816SMartin Matuska.Sy ZDB , 21016038816SMartin Matuska.Sy ZED , 21116038816SMartin Matuska.Sy ZFS , 21216038816SMartin Matuska.Sy ZINJECT , 21316038816SMartin Matuskaand 21416038816SMartin Matuska.Sy ZPOOL . 21516038816SMartin MatuskaThese variables may be overridden in the rc file. 21616038816SMartin Matuska. 21716038816SMartin Matuska.Sh FILES 21816038816SMartin Matuska.Bl -tag -width "-c" 21916038816SMartin Matuska.It Pa @sysconfdir@/zfs/zed.d 220eda14cbcSMatt MacyThe default directory for enabled ZEDLETs. 22116038816SMartin Matuska.It Pa @sysconfdir@/zfs/zed.d/zed.rc 222eda14cbcSMatt MacyThe default rc file for common variables used by ZEDLETs. 22316038816SMartin Matuska.It Pa @zfsexecdir@/zed.d 224eda14cbcSMatt MacyThe default directory for installed ZEDLETs. 22516038816SMartin Matuska.It Pa @runstatedir@/zed.pid 226eda14cbcSMatt MacyThe default file containing the daemon's process ID. 22716038816SMartin Matuska.It Pa @runstatedir@/zed.state 228eda14cbcSMatt MacyThe default file containing the daemon's state. 22916038816SMartin Matuska.El 23016038816SMartin Matuska. 23116038816SMartin Matuska.Sh SIGNALS 23216038816SMartin Matuska.Bl -tag -width "-c" 23316038816SMartin Matuska.It Sy SIGHUP 234eda14cbcSMatt MacyReconfigure the daemon and rescan the directory for enabled ZEDLETs. 23516038816SMartin Matuska.It Sy SIGTERM , SIGINT 236eda14cbcSMatt MacyTerminate the daemon. 23716038816SMartin Matuska.El 23816038816SMartin Matuska. 23916038816SMartin Matuska.Sh SEE ALSO 24016038816SMartin Matuska.Xr zfs 8 , 24116038816SMartin Matuska.Xr zpool 8 , 24216038816SMartin Matuska.Xr zpool-events 8 24316038816SMartin Matuska. 24416038816SMartin Matuska.Sh NOTES 24516038816SMartin MatuskaThe 24616038816SMartin Matuska.Nm 24716038816SMartin Matuskarequires root privileges. 24816038816SMartin Matuska.Pp 24916038816SMartin MatuskaDo not taunt the 25016038816SMartin Matuska.Nm . 25116038816SMartin Matuska. 25216038816SMartin Matuska.Sh BUGS 253eda14cbcSMatt MacyZEDLETs are unable to return state/status information to the kernel. 25416038816SMartin Matuska.Pp 255eda14cbcSMatt MacyInternationalization support via gettext has not been added. 256