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 30*08aba0aeSMartin Matuska.Op Fl b Ar buflen 3116038816SMartin Matuska. 3216038816SMartin Matuska.Sh DESCRIPTION 3316038816SMartin MatuskaThe 3416038816SMartin Matuska.Nm 3516038816SMartin Matuska(ZFS Event Daemon) monitors events generated by the ZFS kernel 3616038816SMartin Matuskamodule. 3716038816SMartin MatuskaWhen a zevent (ZFS Event) is posted, the 3816038816SMartin Matuska.Nm 3916038816SMartin Matuskawill run any ZEDLETs (ZFS Event Daemon Linkage for Executable Tasks) 4016038816SMartin Matuskathat have been enabled for the corresponding zevent class. 4116038816SMartin Matuska. 4216038816SMartin Matuska.Sh OPTIONS 4316038816SMartin Matuska.Bl -tag -width "-h" 4416038816SMartin Matuska.It Fl h 45eda14cbcSMatt MacyDisplay a summary of the command-line options. 4616038816SMartin Matuska.It Fl L 47eda14cbcSMatt MacyDisplay license information. 4816038816SMartin Matuska.It Fl V 49eda14cbcSMatt MacyDisplay version information. 5016038816SMartin Matuska.It Fl v 51eda14cbcSMatt MacyBe verbose. 5216038816SMartin Matuska.It Fl f 53eda14cbcSMatt MacyForce the daemon to run if at all possible, disabling security checks and 5416038816SMartin Matuskathrowing caution to the wind. 5516038816SMartin MatuskaNot recommended for use in production. 5616038816SMartin Matuska.It Fl F 5716038816SMartin MatuskaDon't daemonise: remain attached to the controlling terminal, 5816038816SMartin Matuskalog to the standard I/O streams. 5916038816SMartin Matuska.It Fl M 60eda14cbcSMatt MacyLock all current and future pages in the virtual memory address space. 61eda14cbcSMatt MacyThis may help the daemon remain responsive when the system is under heavy 62eda14cbcSMatt Macymemory pressure. 6316038816SMartin Matuska.It Fl I 6416038816SMartin MatuskaRequest that the daemon idle rather than exit when the kernel modules are not loaded. 6516038816SMartin MatuskaProcessing of events will start, or resume, when the kernel modules are (re)loaded. 6616038816SMartin MatuskaUnder Linux the kernel modules cannot be unloaded while the daemon is running. 6716038816SMartin Matuska.It Fl Z 68eda14cbcSMatt MacyZero the daemon's state, thereby allowing zevents still within the kernel 69eda14cbcSMatt Macyto be reprocessed. 7016038816SMartin Matuska.It Fl d Ar zedletdir 71eda14cbcSMatt MacyRead the enabled ZEDLETs from the specified directory. 7216038816SMartin Matuska.It Fl p Ar pidfile 73eda14cbcSMatt MacyWrite the daemon's process ID to the specified file. 7416038816SMartin Matuska.It Fl P Ar path 7516038816SMartin MatuskaCustom 7616038816SMartin Matuska.Ev $PATH 7716038816SMartin Matuskafor zedlets to use. 7816038816SMartin MatuskaNormally zedlets run in a locked-down environment, with hardcoded paths to the ZFS commands 79716fd348SMartin Matuska.Pq Ev $ZFS , $ZPOOL , $ZED , … , 8016038816SMartin Matuskaand a hard-coded 8116038816SMartin Matuska.Ev $PATH . 8216038816SMartin MatuskaThis is done for security reasons. 8316038816SMartin MatuskaHowever, the ZFS test suite uses a custom PATH for its ZFS commands, and passes it to 8416038816SMartin Matuska.Nm 8516038816SMartin Matuskawith 8616038816SMartin Matuska.Fl P . 8716038816SMartin MatuskaIn short, 8816038816SMartin Matuska.Fl P 8916038816SMartin Matuskais only to be used by the ZFS test suite; never use 90eda14cbcSMatt Macyit in production! 9116038816SMartin Matuska.It Fl s Ar statefile 92eda14cbcSMatt MacyWrite the daemon's state to the specified file. 9316038816SMartin Matuska.It Fl j Ar jobs 9416038816SMartin MatuskaAllow at most 9516038816SMartin Matuska.Ar jobs 9616038816SMartin MatuskaZEDLETs to run concurrently, 9716038816SMartin Matuskadelaying execution of new ones until they finish. 9816038816SMartin MatuskaDefaults to 9916038816SMartin Matuska.Sy 16 . 100*08aba0aeSMartin Matuska.It Fl b Ar buflen 101*08aba0aeSMartin MatuskaCap kernel event buffer growth to 102*08aba0aeSMartin Matuska.Ar buflen 103*08aba0aeSMartin Matuskaentries. 104*08aba0aeSMartin MatuskaThis buffer is grown when the daemon misses an event, but results in 105*08aba0aeSMartin Matuskaunreclaimable memory use in the kernel. 106*08aba0aeSMartin MatuskaA value of 107*08aba0aeSMartin Matuska.Sy 0 108*08aba0aeSMartin Matuskaremoves the cap. 109*08aba0aeSMartin MatuskaDefaults to 110*08aba0aeSMartin Matuska.Sy 1048576 . 11116038816SMartin Matuska.El 11216038816SMartin Matuska.Sh ZEVENTS 11316038816SMartin MatuskaA zevent is comprised of a list of nvpairs (name/value pairs). 11416038816SMartin MatuskaEach zevent contains an EID (Event IDentifier) that uniquely identifies it throughout 115eda14cbcSMatt Macythe lifetime of the loaded ZFS kernel module; this EID is a monotonically 116eda14cbcSMatt Macyincreasing integer that resets to 1 each time the kernel module is loaded. 117eda14cbcSMatt MacyEach zevent also contains a class string that identifies the type of event. 118eda14cbcSMatt MacyFor brevity, a subclass string is defined that omits the leading components 11916038816SMartin Matuskaof the class string. 12016038816SMartin MatuskaAdditional nvpairs exist to provide event details. 12116038816SMartin Matuska.Pp 122eda14cbcSMatt MacyThe kernel maintains a list of recent zevents that can be viewed (along with 12316038816SMartin Matuskatheir associated lists of nvpairs) using the 12416038816SMartin Matuska.Nm zpool Cm events Fl v 12516038816SMartin Matuskacommand. 12616038816SMartin Matuska. 12716038816SMartin Matuska.Sh CONFIGURATION 128eda14cbcSMatt MacyZEDLETs to be invoked in response to zevents are located in the 12916038816SMartin Matuska.Em enabled-zedlets 13016038816SMartin Matuskadirectory 13116038816SMartin Matuska.Pq Ar zedletdir . 13216038816SMartin MatuskaThese can be symlinked or copied from the 13316038816SMartin Matuska.Em installed-zedlets 13416038816SMartin Matuskadirectory; symlinks allow for automatic updates 135eda14cbcSMatt Macyfrom the installed ZEDLETs, whereas copies preserve local modifications. 13616038816SMartin MatuskaAs a security measure, since ownership change is a privileged operation, 13716038816SMartin MatuskaZEDLETs must be owned by root. 13816038816SMartin MatuskaThey must have execute permissions for the user, 13916038816SMartin Matuskabut they must not have write permissions for group or other. 14016038816SMartin MatuskaDotfiles are ignored. 14116038816SMartin Matuska.Pp 142eda14cbcSMatt MacyZEDLETs are named after the zevent class for which they should be invoked. 143eda14cbcSMatt MacyIn particular, a ZEDLET will be invoked for a given zevent if either its 144eda14cbcSMatt Macyclass or subclass string is a prefix of its filename (and is followed by 14516038816SMartin Matuskaa non-alphabetic character). 14616038816SMartin MatuskaAs a special case, the prefix 14716038816SMartin Matuska.Sy all 14816038816SMartin Matuskamatches all zevents. 14916038816SMartin MatuskaMultiple ZEDLETs may be invoked for a given zevent. 15016038816SMartin Matuska. 15116038816SMartin Matuska.Sh ZEDLETS 152eda14cbcSMatt MacyZEDLETs are executables invoked by the ZED in response to a given zevent. 153eda14cbcSMatt MacyThey should be written under the presumption they can be invoked concurrently, 154eda14cbcSMatt Macyand they should use appropriate locking to access any shared resources. 155eda14cbcSMatt MacyCommon variables used by ZEDLETs can be stored in the default rc file which 15616038816SMartin Matuskais sourced by scripts; these variables should be prefixed with 15716038816SMartin Matuska.Sy ZED_ . 15816038816SMartin Matuska.Pp 159eda14cbcSMatt MacyThe zevent nvpairs are passed to ZEDLETs as environment variables. 160eda14cbcSMatt MacyEach nvpair name is converted to an environment variable in the following 16116038816SMartin Matuskamanner: 1623ff01b23SMartin Matuska.Bl -enum -compact 16316038816SMartin Matuska.It 16416038816SMartin Matuskait is prefixed with 16516038816SMartin Matuska.Sy ZEVENT_ , 16616038816SMartin Matuska.It 16716038816SMartin Matuskait is converted to uppercase, and 16816038816SMartin Matuska.It 16916038816SMartin Matuskaeach non-alphanumeric character is converted to an underscore. 17016038816SMartin Matuska.El 17116038816SMartin Matuska.Pp 172eda14cbcSMatt MacySome additional environment variables have been defined to present certain 17316038816SMartin Matuskanvpair values in a more convenient form. 17416038816SMartin MatuskaAn incomplete list of zevent environment variables is as follows: 1753ff01b23SMartin Matuska.Bl -tag -compact -width "ZEVENT_TIME_STRING" 17616038816SMartin Matuska.It Sy ZEVENT_EID 177eda14cbcSMatt MacyThe Event IDentifier. 17816038816SMartin Matuska.It Sy ZEVENT_CLASS 179eda14cbcSMatt MacyThe zevent class string. 18016038816SMartin Matuska.It Sy ZEVENT_SUBCLASS 181eda14cbcSMatt MacyThe zevent subclass string. 18216038816SMartin Matuska.It Sy ZEVENT_TIME 183eda14cbcSMatt MacyThe time at which the zevent was posted as 18416038816SMartin Matuska.Dq Em seconds nanoseconds 18516038816SMartin Matuskasince the Epoch. 18616038816SMartin Matuska.It Sy ZEVENT_TIME_SECS 18716038816SMartin MatuskaThe 18816038816SMartin Matuska.Em seconds 18916038816SMartin Matuskacomponent of 19016038816SMartin Matuska.Sy ZEVENT_TIME . 19116038816SMartin Matuska.It Sy ZEVENT_TIME_NSECS 19216038816SMartin MatuskaThe 19316038816SMartin Matuska.Em nanoseconds 19416038816SMartin Matuskacomponent of 19516038816SMartin Matuska.Sy ZEVENT_TIME . 19616038816SMartin Matuska.It Sy ZEVENT_TIME_STRING 19716038816SMartin MatuskaAn almost-RFC3339-compliant string for 19816038816SMartin Matuska.Sy ZEVENT_TIME . 19916038816SMartin Matuska.El 20016038816SMartin Matuska.Pp 201eda14cbcSMatt MacyAdditionally, the following ZED & ZFS variables are defined: 2023ff01b23SMartin Matuska.Bl -tag -compact -width "ZEVENT_TIME_STRING" 20316038816SMartin Matuska.It Sy ZED_PID 204eda14cbcSMatt MacyThe daemon's process ID. 20516038816SMartin Matuska.It Sy ZED_ZEDLET_DIR 20616038816SMartin MatuskaThe daemon's current 20716038816SMartin Matuska.Em enabled-zedlets 20816038816SMartin Matuskadirectory. 20916038816SMartin Matuska.It Sy ZFS_ALIAS 21016038816SMartin MatuskaThe alias 21116038816SMartin Matuska.Pq Dq Em name Ns - Ns Em version Ns - Ns Em release 21216038816SMartin Matuskastring of the ZFS distribution the daemon is part of. 21316038816SMartin Matuska.It Sy ZFS_VERSION 21416038816SMartin MatuskaThe ZFS version the daemon is part of. 21516038816SMartin Matuska.It Sy ZFS_RELEASE 21616038816SMartin MatuskaThe ZFS release the daemon is part of. 21716038816SMartin Matuska.El 21816038816SMartin Matuska.Pp 21916038816SMartin MatuskaZEDLETs may need to call other ZFS commands. 22016038816SMartin MatuskaThe installation paths of the following executables are defined as environment variables: 22116038816SMartin Matuska.Sy ZDB , 22216038816SMartin Matuska.Sy ZED , 22316038816SMartin Matuska.Sy ZFS , 22416038816SMartin Matuska.Sy ZINJECT , 22516038816SMartin Matuskaand 22616038816SMartin Matuska.Sy ZPOOL . 22716038816SMartin MatuskaThese variables may be overridden in the rc file. 22816038816SMartin Matuska. 22916038816SMartin Matuska.Sh FILES 23016038816SMartin Matuska.Bl -tag -width "-c" 23116038816SMartin Matuska.It Pa @sysconfdir@/zfs/zed.d 232eda14cbcSMatt MacyThe default directory for enabled ZEDLETs. 23316038816SMartin Matuska.It Pa @sysconfdir@/zfs/zed.d/zed.rc 234eda14cbcSMatt MacyThe default rc file for common variables used by ZEDLETs. 23516038816SMartin Matuska.It Pa @zfsexecdir@/zed.d 236eda14cbcSMatt MacyThe default directory for installed ZEDLETs. 23716038816SMartin Matuska.It Pa @runstatedir@/zed.pid 238eda14cbcSMatt MacyThe default file containing the daemon's process ID. 23916038816SMartin Matuska.It Pa @runstatedir@/zed.state 240eda14cbcSMatt MacyThe default file containing the daemon's state. 24116038816SMartin Matuska.El 24216038816SMartin Matuska. 24316038816SMartin Matuska.Sh SIGNALS 24416038816SMartin Matuska.Bl -tag -width "-c" 24516038816SMartin Matuska.It Sy SIGHUP 246eda14cbcSMatt MacyReconfigure the daemon and rescan the directory for enabled ZEDLETs. 24716038816SMartin Matuska.It Sy SIGTERM , SIGINT 248eda14cbcSMatt MacyTerminate the daemon. 24916038816SMartin Matuska.El 25016038816SMartin Matuska. 25116038816SMartin Matuska.Sh SEE ALSO 25216038816SMartin Matuska.Xr zfs 8 , 25316038816SMartin Matuska.Xr zpool 8 , 25416038816SMartin Matuska.Xr zpool-events 8 25516038816SMartin Matuska. 25616038816SMartin Matuska.Sh NOTES 25716038816SMartin MatuskaThe 25816038816SMartin Matuska.Nm 25916038816SMartin Matuskarequires root privileges. 26016038816SMartin Matuska.Pp 26116038816SMartin MatuskaDo not taunt the 26216038816SMartin Matuska.Nm . 26316038816SMartin Matuska. 26416038816SMartin Matuska.Sh BUGS 265eda14cbcSMatt MacyZEDLETs are unable to return state/status information to the kernel. 26616038816SMartin Matuska.Pp 267eda14cbcSMatt MacyInternationalization support via gettext has not been added. 268