xref: /freebsd/sys/contrib/openzfs/man/man8/zed.8.in (revision 61145dc2b94f12f6a47344fb9aac702321880e43)
1*61145dc2SMartin Matuska.\" SPDX-License-Identifier: CDDL-1.0
2eda14cbcSMatt Macy.\"
3180f8225SMatt Macy.\" This file is part of the ZFS Event Daemon (ZED).
4eda14cbcSMatt Macy.\" Developed at Lawrence Livermore National Laboratory (LLNL-CODE-403049).
5eda14cbcSMatt Macy.\" Copyright (C) 2013-2014 Lawrence Livermore National Security, LLC.
616038816SMartin Matuska.\" Refer to the OpenZFS git commit log for authoritative copyright attribution.
7eda14cbcSMatt Macy.\"
8eda14cbcSMatt Macy.\" The contents of this file are subject to the terms of the
9eda14cbcSMatt Macy.\" Common Development and Distribution License Version 1.0 (CDDL-1.0).
10eda14cbcSMatt Macy.\" You can obtain a copy of the license from the top-level file
11eda14cbcSMatt Macy.\" "OPENSOLARIS.LICENSE" or at <http://opensource.org/licenses/CDDL-1.0>.
12eda14cbcSMatt Macy.\" You may not use this file except in compliance with the license.
13eda14cbcSMatt Macy.\"
1416038816SMartin Matuska.\" Developed at Lawrence Livermore National Laboratory (LLNL-CODE-403049)
1516038816SMartin Matuska.\"
1616038816SMartin Matuska.Dd May 26, 2021
1716038816SMartin Matuska.Dt ZED 8
1816038816SMartin Matuska.Os
1916038816SMartin Matuska.
2016038816SMartin Matuska.Sh NAME
2116038816SMartin Matuska.Nm ZED
2216038816SMartin Matuska.Nd ZFS Event Daemon
2316038816SMartin Matuska.Sh SYNOPSIS
2416038816SMartin Matuska.Nm
2516038816SMartin Matuska.Op Fl fFhILMvVZ
2616038816SMartin Matuska.Op Fl d Ar zedletdir
2716038816SMartin Matuska.Op Fl p Ar pidfile
2816038816SMartin Matuska.Op Fl P Ar path
2916038816SMartin Matuska.Op Fl s Ar statefile
3016038816SMartin Matuska.Op Fl j Ar jobs
3108aba0aeSMartin Matuska.Op Fl b Ar buflen
3216038816SMartin Matuska.
3316038816SMartin Matuska.Sh DESCRIPTION
3416038816SMartin MatuskaThe
3516038816SMartin Matuska.Nm
3616038816SMartin Matuska(ZFS Event Daemon) monitors events generated by the ZFS kernel
3716038816SMartin Matuskamodule.
3816038816SMartin MatuskaWhen a zevent (ZFS Event) is posted, the
3916038816SMartin Matuska.Nm
4016038816SMartin Matuskawill run any ZEDLETs (ZFS Event Daemon Linkage for Executable Tasks)
4116038816SMartin Matuskathat have been enabled for the corresponding zevent class.
4216038816SMartin Matuska.
4316038816SMartin Matuska.Sh OPTIONS
4416038816SMartin Matuska.Bl -tag -width "-h"
4516038816SMartin Matuska.It Fl h
46eda14cbcSMatt MacyDisplay a summary of the command-line options.
4716038816SMartin Matuska.It Fl L
48eda14cbcSMatt MacyDisplay license information.
4916038816SMartin Matuska.It Fl V
50eda14cbcSMatt MacyDisplay version information.
5116038816SMartin Matuska.It Fl v
52eda14cbcSMatt MacyBe verbose.
5316038816SMartin Matuska.It Fl f
54eda14cbcSMatt MacyForce the daemon to run if at all possible, disabling security checks and
5516038816SMartin Matuskathrowing caution to the wind.
5616038816SMartin MatuskaNot recommended for use in production.
5716038816SMartin Matuska.It Fl F
58*61145dc2SMartin MatuskaDon't daemonize: remain attached to the controlling terminal,
5916038816SMartin Matuskalog to the standard I/O streams.
6016038816SMartin Matuska.It Fl M
61eda14cbcSMatt MacyLock all current and future pages in the virtual memory address space.
62eda14cbcSMatt MacyThis may help the daemon remain responsive when the system is under heavy
63eda14cbcSMatt Macymemory pressure.
6416038816SMartin Matuska.It Fl I
65bb2d13b6SMartin MatuskaRequest that the daemon idle rather than exit when the kernel modules are not
66bb2d13b6SMartin Matuskaloaded.
67bb2d13b6SMartin MatuskaProcessing of events will start, or resume, when the kernel modules are
68bb2d13b6SMartin Matuska(re)loaded.
6916038816SMartin MatuskaUnder Linux the kernel modules cannot be unloaded while the daemon is running.
7016038816SMartin Matuska.It Fl Z
71eda14cbcSMatt MacyZero the daemon's state, thereby allowing zevents still within the kernel
72eda14cbcSMatt Macyto be reprocessed.
7316038816SMartin Matuska.It Fl d Ar zedletdir
74eda14cbcSMatt MacyRead the enabled ZEDLETs from the specified directory.
7516038816SMartin Matuska.It Fl p Ar pidfile
76eda14cbcSMatt MacyWrite the daemon's process ID to the specified file.
7716038816SMartin Matuska.It Fl P Ar path
7816038816SMartin MatuskaCustom
7916038816SMartin Matuska.Ev $PATH
8016038816SMartin Matuskafor zedlets to use.
81bb2d13b6SMartin MatuskaNormally zedlets run in a locked-down environment, with hardcoded paths to the
82bb2d13b6SMartin MatuskaZFS commands
83716fd348SMartin Matuska.Pq Ev $ZFS , $ZPOOL , $ZED , … ,
8416038816SMartin Matuskaand a hard-coded
8516038816SMartin Matuska.Ev $PATH .
8616038816SMartin MatuskaThis is done for security reasons.
87bb2d13b6SMartin MatuskaHowever, the ZFS test suite uses a custom PATH for its ZFS commands, and passes
88bb2d13b6SMartin Matuskait to
8916038816SMartin Matuska.Nm
9016038816SMartin Matuskawith
9116038816SMartin Matuska.Fl P .
9216038816SMartin MatuskaIn short,
9316038816SMartin Matuska.Fl P
9416038816SMartin Matuskais only to be used by the ZFS test suite; never use
95eda14cbcSMatt Macyit in production!
9616038816SMartin Matuska.It Fl s Ar statefile
97eda14cbcSMatt MacyWrite the daemon's state to the specified file.
9816038816SMartin Matuska.It Fl j Ar jobs
9916038816SMartin MatuskaAllow at most
10016038816SMartin Matuska.Ar jobs
10116038816SMartin MatuskaZEDLETs to run concurrently,
10216038816SMartin Matuskadelaying execution of new ones until they finish.
10316038816SMartin MatuskaDefaults to
10416038816SMartin Matuska.Sy 16 .
10508aba0aeSMartin Matuska.It Fl b Ar buflen
10608aba0aeSMartin MatuskaCap kernel event buffer growth to
10708aba0aeSMartin Matuska.Ar buflen
10808aba0aeSMartin Matuskaentries.
10908aba0aeSMartin MatuskaThis buffer is grown when the daemon misses an event, but results in
11008aba0aeSMartin Matuskaunreclaimable memory use in the kernel.
11108aba0aeSMartin MatuskaA value of
11208aba0aeSMartin Matuska.Sy 0
11308aba0aeSMartin Matuskaremoves the cap.
11408aba0aeSMartin MatuskaDefaults to
11508aba0aeSMartin Matuska.Sy 1048576 .
11616038816SMartin Matuska.El
11716038816SMartin Matuska.Sh ZEVENTS
11816038816SMartin MatuskaA zevent is comprised of a list of nvpairs (name/value pairs).
119bb2d13b6SMartin MatuskaEach zevent contains an EID (Event IDentifier) that uniquely identifies it
120bb2d13b6SMartin Matuskathroughout
121eda14cbcSMatt Macythe lifetime of the loaded ZFS kernel module; this EID is a monotonically
122eda14cbcSMatt Macyincreasing integer that resets to 1 each time the kernel module is loaded.
123eda14cbcSMatt MacyEach zevent also contains a class string that identifies the type of event.
124eda14cbcSMatt MacyFor brevity, a subclass string is defined that omits the leading components
12516038816SMartin Matuskaof the class string.
12616038816SMartin MatuskaAdditional nvpairs exist to provide event details.
12716038816SMartin Matuska.Pp
128eda14cbcSMatt MacyThe kernel maintains a list of recent zevents that can be viewed (along with
12916038816SMartin Matuskatheir associated lists of nvpairs) using the
13016038816SMartin Matuska.Nm zpool Cm events Fl v
13116038816SMartin Matuskacommand.
13216038816SMartin Matuska.
13316038816SMartin Matuska.Sh CONFIGURATION
134eda14cbcSMatt MacyZEDLETs to be invoked in response to zevents are located in the
13516038816SMartin Matuska.Em enabled-zedlets
13616038816SMartin Matuskadirectory
13716038816SMartin Matuska.Pq Ar zedletdir .
13816038816SMartin MatuskaThese can be symlinked or copied from the
13916038816SMartin Matuska.Em installed-zedlets
14016038816SMartin Matuskadirectory; symlinks allow for automatic updates
141eda14cbcSMatt Macyfrom the installed ZEDLETs, whereas copies preserve local modifications.
14216038816SMartin MatuskaAs a security measure, since ownership change is a privileged operation,
14316038816SMartin MatuskaZEDLETs must be owned by root.
14416038816SMartin MatuskaThey must have execute permissions for the user,
14516038816SMartin Matuskabut they must not have write permissions for group or other.
14616038816SMartin MatuskaDotfiles are ignored.
14716038816SMartin Matuska.Pp
148eda14cbcSMatt MacyZEDLETs are named after the zevent class for which they should be invoked.
149eda14cbcSMatt MacyIn particular, a ZEDLET will be invoked for a given zevent if either its
150eda14cbcSMatt Macyclass or subclass string is a prefix of its filename (and is followed by
15116038816SMartin Matuskaa non-alphabetic character).
15216038816SMartin MatuskaAs a special case, the prefix
15316038816SMartin Matuska.Sy all
15416038816SMartin Matuskamatches all zevents.
15516038816SMartin MatuskaMultiple ZEDLETs may be invoked for a given zevent.
15616038816SMartin Matuska.
15716038816SMartin Matuska.Sh ZEDLETS
158eda14cbcSMatt MacyZEDLETs are executables invoked by the ZED in response to a given zevent.
159eda14cbcSMatt MacyThey should be written under the presumption they can be invoked concurrently,
160eda14cbcSMatt Macyand they should use appropriate locking to access any shared resources.
161eda14cbcSMatt MacyCommon variables used by ZEDLETs can be stored in the default rc file which
16216038816SMartin Matuskais sourced by scripts; these variables should be prefixed with
16316038816SMartin Matuska.Sy ZED_ .
16416038816SMartin Matuska.Pp
165eda14cbcSMatt MacyThe zevent nvpairs are passed to ZEDLETs as environment variables.
166eda14cbcSMatt MacyEach nvpair name is converted to an environment variable in the following
16716038816SMartin Matuskamanner:
1683ff01b23SMartin Matuska.Bl -enum -compact
16916038816SMartin Matuska.It
17016038816SMartin Matuskait is prefixed with
17116038816SMartin Matuska.Sy ZEVENT_ ,
17216038816SMartin Matuska.It
17316038816SMartin Matuskait is converted to uppercase, and
17416038816SMartin Matuska.It
17516038816SMartin Matuskaeach non-alphanumeric character is converted to an underscore.
17616038816SMartin Matuska.El
17716038816SMartin Matuska.Pp
178eda14cbcSMatt MacySome additional environment variables have been defined to present certain
17916038816SMartin Matuskanvpair values in a more convenient form.
18016038816SMartin MatuskaAn incomplete list of zevent environment variables is as follows:
1813ff01b23SMartin Matuska.Bl -tag -compact -width "ZEVENT_TIME_STRING"
18216038816SMartin Matuska.It Sy ZEVENT_EID
183eda14cbcSMatt MacyThe Event IDentifier.
18416038816SMartin Matuska.It Sy ZEVENT_CLASS
185eda14cbcSMatt MacyThe zevent class string.
18616038816SMartin Matuska.It Sy ZEVENT_SUBCLASS
187eda14cbcSMatt MacyThe zevent subclass string.
18816038816SMartin Matuska.It Sy ZEVENT_TIME
189eda14cbcSMatt MacyThe time at which the zevent was posted as
19016038816SMartin Matuska.Dq Em seconds nanoseconds
19116038816SMartin Matuskasince the Epoch.
19216038816SMartin Matuska.It Sy ZEVENT_TIME_SECS
19316038816SMartin MatuskaThe
19416038816SMartin Matuska.Em seconds
19516038816SMartin Matuskacomponent of
19616038816SMartin Matuska.Sy ZEVENT_TIME .
19716038816SMartin Matuska.It Sy ZEVENT_TIME_NSECS
19816038816SMartin MatuskaThe
19916038816SMartin Matuska.Em nanoseconds
20016038816SMartin Matuskacomponent of
20116038816SMartin Matuska.Sy ZEVENT_TIME .
20216038816SMartin Matuska.It Sy ZEVENT_TIME_STRING
20316038816SMartin MatuskaAn almost-RFC3339-compliant string for
20416038816SMartin Matuska.Sy ZEVENT_TIME .
20516038816SMartin Matuska.El
20616038816SMartin Matuska.Pp
207eda14cbcSMatt MacyAdditionally, the following ZED & ZFS variables are defined:
2083ff01b23SMartin Matuska.Bl -tag -compact -width "ZEVENT_TIME_STRING"
20916038816SMartin Matuska.It Sy ZED_PID
210eda14cbcSMatt MacyThe daemon's process ID.
21116038816SMartin Matuska.It Sy ZED_ZEDLET_DIR
21216038816SMartin MatuskaThe daemon's current
21316038816SMartin Matuska.Em enabled-zedlets
21416038816SMartin Matuskadirectory.
21516038816SMartin Matuska.It Sy ZFS_ALIAS
21616038816SMartin MatuskaThe alias
21716038816SMartin Matuska.Pq Dq Em name Ns - Ns Em version Ns - Ns Em release
21816038816SMartin Matuskastring of the ZFS distribution the daemon is part of.
21916038816SMartin Matuska.It Sy ZFS_VERSION
22016038816SMartin MatuskaThe ZFS version the daemon is part of.
22116038816SMartin Matuska.It Sy ZFS_RELEASE
22216038816SMartin MatuskaThe ZFS release the daemon is part of.
22316038816SMartin Matuska.El
22416038816SMartin Matuska.Pp
22516038816SMartin MatuskaZEDLETs may need to call other ZFS commands.
226bb2d13b6SMartin MatuskaThe installation paths of the following executables are defined as environment
227bb2d13b6SMartin Matuskavariables:
22816038816SMartin Matuska.Sy ZDB ,
22916038816SMartin Matuska.Sy ZED ,
23016038816SMartin Matuska.Sy ZFS ,
23116038816SMartin Matuska.Sy ZINJECT ,
23216038816SMartin Matuskaand
23316038816SMartin Matuska.Sy ZPOOL .
23416038816SMartin MatuskaThese variables may be overridden in the rc file.
23516038816SMartin Matuska.
23616038816SMartin Matuska.Sh FILES
23716038816SMartin Matuska.Bl -tag -width "-c"
23816038816SMartin Matuska.It Pa @sysconfdir@/zfs/zed.d
239eda14cbcSMatt MacyThe default directory for enabled ZEDLETs.
24016038816SMartin Matuska.It Pa @sysconfdir@/zfs/zed.d/zed.rc
241eda14cbcSMatt MacyThe default rc file for common variables used by ZEDLETs.
24216038816SMartin Matuska.It Pa @zfsexecdir@/zed.d
243eda14cbcSMatt MacyThe default directory for installed ZEDLETs.
24416038816SMartin Matuska.It Pa @runstatedir@/zed.pid
245eda14cbcSMatt MacyThe default file containing the daemon's process ID.
24616038816SMartin Matuska.It Pa @runstatedir@/zed.state
247eda14cbcSMatt MacyThe default file containing the daemon's state.
24816038816SMartin Matuska.El
24916038816SMartin Matuska.
25016038816SMartin Matuska.Sh SIGNALS
25116038816SMartin Matuska.Bl -tag -width "-c"
25216038816SMartin Matuska.It Sy SIGHUP
253eda14cbcSMatt MacyReconfigure the daemon and rescan the directory for enabled ZEDLETs.
25416038816SMartin Matuska.It Sy SIGTERM , SIGINT
255eda14cbcSMatt MacyTerminate the daemon.
25616038816SMartin Matuska.El
25716038816SMartin Matuska.
25816038816SMartin Matuska.Sh SEE ALSO
25916038816SMartin Matuska.Xr zfs 8 ,
26016038816SMartin Matuska.Xr zpool 8 ,
26116038816SMartin Matuska.Xr zpool-events 8
26216038816SMartin Matuska.
26316038816SMartin Matuska.Sh NOTES
26416038816SMartin MatuskaThe
26516038816SMartin Matuska.Nm
26616038816SMartin Matuskarequires root privileges.
26716038816SMartin Matuska.Pp
26816038816SMartin MatuskaDo not taunt the
26916038816SMartin Matuska.Nm .
27016038816SMartin Matuska.
27116038816SMartin Matuska.Sh BUGS
272eda14cbcSMatt MacyZEDLETs are unable to return state/status information to the kernel.
27316038816SMartin Matuska.Pp
274eda14cbcSMatt MacyInternationalization support via gettext has not been added.
275