1.\" 2.\" This file is part of the ZFS Event Daemon (ZED). 3.\" Developed at Lawrence Livermore National Laboratory (LLNL-CODE-403049). 4.\" Copyright (C) 2013-2014 Lawrence Livermore National Security, LLC. 5.\" Refer to the OpenZFS git commit log for authoritative copyright attribution. 6.\" 7.\" The contents of this file are subject to the terms of the 8.\" Common Development and Distribution License Version 1.0 (CDDL-1.0). 9.\" You can obtain a copy of the license from the top-level file 10.\" "OPENSOLARIS.LICENSE" or at <http://opensource.org/licenses/CDDL-1.0>. 11.\" You may not use this file except in compliance with the license. 12.\" 13.\" Developed at Lawrence Livermore National Laboratory (LLNL-CODE-403049) 14.\" 15.Dd May 26, 2021 16.Dt ZED 8 17.Os 18. 19.Sh NAME 20.Nm ZED 21.Nd ZFS Event Daemon 22.Sh SYNOPSIS 23.Nm 24.Op Fl fFhILMvVZ 25.Op Fl d Ar zedletdir 26.Op Fl p Ar pidfile 27.Op Fl P Ar path 28.Op Fl s Ar statefile 29.Op Fl j Ar jobs 30.Op Fl b Ar buflen 31. 32.Sh DESCRIPTION 33The 34.Nm 35(ZFS Event Daemon) monitors events generated by the ZFS kernel 36module. 37When a zevent (ZFS Event) is posted, the 38.Nm 39will run any ZEDLETs (ZFS Event Daemon Linkage for Executable Tasks) 40that have been enabled for the corresponding zevent class. 41. 42.Sh OPTIONS 43.Bl -tag -width "-h" 44.It Fl h 45Display a summary of the command-line options. 46.It Fl L 47Display license information. 48.It Fl V 49Display version information. 50.It Fl v 51Be verbose. 52.It Fl f 53Force the daemon to run if at all possible, disabling security checks and 54throwing caution to the wind. 55Not recommended for use in production. 56.It Fl F 57Don't daemonise: remain attached to the controlling terminal, 58log to the standard I/O streams. 59.It Fl M 60Lock all current and future pages in the virtual memory address space. 61This may help the daemon remain responsive when the system is under heavy 62memory pressure. 63.It Fl I 64Request that the daemon idle rather than exit when the kernel modules are not 65loaded. 66Processing of events will start, or resume, when the kernel modules are 67(re)loaded. 68Under Linux the kernel modules cannot be unloaded while the daemon is running. 69.It Fl Z 70Zero the daemon's state, thereby allowing zevents still within the kernel 71to be reprocessed. 72.It Fl d Ar zedletdir 73Read the enabled ZEDLETs from the specified directory. 74.It Fl p Ar pidfile 75Write the daemon's process ID to the specified file. 76.It Fl P Ar path 77Custom 78.Ev $PATH 79for zedlets to use. 80Normally zedlets run in a locked-down environment, with hardcoded paths to the 81ZFS commands 82.Pq Ev $ZFS , $ZPOOL , $ZED , … , 83and a hard-coded 84.Ev $PATH . 85This is done for security reasons. 86However, the ZFS test suite uses a custom PATH for its ZFS commands, and passes 87it to 88.Nm 89with 90.Fl P . 91In short, 92.Fl P 93is only to be used by the ZFS test suite; never use 94it in production! 95.It Fl s Ar statefile 96Write the daemon's state to the specified file. 97.It Fl j Ar jobs 98Allow at most 99.Ar jobs 100ZEDLETs to run concurrently, 101delaying execution of new ones until they finish. 102Defaults to 103.Sy 16 . 104.It Fl b Ar buflen 105Cap kernel event buffer growth to 106.Ar buflen 107entries. 108This buffer is grown when the daemon misses an event, but results in 109unreclaimable memory use in the kernel. 110A value of 111.Sy 0 112removes the cap. 113Defaults to 114.Sy 1048576 . 115.El 116.Sh ZEVENTS 117A zevent is comprised of a list of nvpairs (name/value pairs). 118Each zevent contains an EID (Event IDentifier) that uniquely identifies it 119throughout 120the lifetime of the loaded ZFS kernel module; this EID is a monotonically 121increasing integer that resets to 1 each time the kernel module is loaded. 122Each zevent also contains a class string that identifies the type of event. 123For brevity, a subclass string is defined that omits the leading components 124of the class string. 125Additional nvpairs exist to provide event details. 126.Pp 127The kernel maintains a list of recent zevents that can be viewed (along with 128their associated lists of nvpairs) using the 129.Nm zpool Cm events Fl v 130command. 131. 132.Sh CONFIGURATION 133ZEDLETs to be invoked in response to zevents are located in the 134.Em enabled-zedlets 135directory 136.Pq Ar zedletdir . 137These can be symlinked or copied from the 138.Em installed-zedlets 139directory; symlinks allow for automatic updates 140from the installed ZEDLETs, whereas copies preserve local modifications. 141As a security measure, since ownership change is a privileged operation, 142ZEDLETs must be owned by root. 143They must have execute permissions for the user, 144but they must not have write permissions for group or other. 145Dotfiles are ignored. 146.Pp 147ZEDLETs are named after the zevent class for which they should be invoked. 148In particular, a ZEDLET will be invoked for a given zevent if either its 149class or subclass string is a prefix of its filename (and is followed by 150a non-alphabetic character). 151As a special case, the prefix 152.Sy all 153matches all zevents. 154Multiple ZEDLETs may be invoked for a given zevent. 155. 156.Sh ZEDLETS 157ZEDLETs are executables invoked by the ZED in response to a given zevent. 158They should be written under the presumption they can be invoked concurrently, 159and they should use appropriate locking to access any shared resources. 160Common variables used by ZEDLETs can be stored in the default rc file which 161is sourced by scripts; these variables should be prefixed with 162.Sy ZED_ . 163.Pp 164The zevent nvpairs are passed to ZEDLETs as environment variables. 165Each nvpair name is converted to an environment variable in the following 166manner: 167.Bl -enum -compact 168.It 169it is prefixed with 170.Sy ZEVENT_ , 171.It 172it is converted to uppercase, and 173.It 174each non-alphanumeric character is converted to an underscore. 175.El 176.Pp 177Some additional environment variables have been defined to present certain 178nvpair values in a more convenient form. 179An incomplete list of zevent environment variables is as follows: 180.Bl -tag -compact -width "ZEVENT_TIME_STRING" 181.It Sy ZEVENT_EID 182The Event IDentifier. 183.It Sy ZEVENT_CLASS 184The zevent class string. 185.It Sy ZEVENT_SUBCLASS 186The zevent subclass string. 187.It Sy ZEVENT_TIME 188The time at which the zevent was posted as 189.Dq Em seconds nanoseconds 190since the Epoch. 191.It Sy ZEVENT_TIME_SECS 192The 193.Em seconds 194component of 195.Sy ZEVENT_TIME . 196.It Sy ZEVENT_TIME_NSECS 197The 198.Em nanoseconds 199component of 200.Sy ZEVENT_TIME . 201.It Sy ZEVENT_TIME_STRING 202An almost-RFC3339-compliant string for 203.Sy ZEVENT_TIME . 204.El 205.Pp 206Additionally, the following ZED & ZFS variables are defined: 207.Bl -tag -compact -width "ZEVENT_TIME_STRING" 208.It Sy ZED_PID 209The daemon's process ID. 210.It Sy ZED_ZEDLET_DIR 211The daemon's current 212.Em enabled-zedlets 213directory. 214.It Sy ZFS_ALIAS 215The alias 216.Pq Dq Em name Ns - Ns Em version Ns - Ns Em release 217string of the ZFS distribution the daemon is part of. 218.It Sy ZFS_VERSION 219The ZFS version the daemon is part of. 220.It Sy ZFS_RELEASE 221The ZFS release the daemon is part of. 222.El 223.Pp 224ZEDLETs may need to call other ZFS commands. 225The installation paths of the following executables are defined as environment 226variables: 227.Sy ZDB , 228.Sy ZED , 229.Sy ZFS , 230.Sy ZINJECT , 231and 232.Sy ZPOOL . 233These variables may be overridden in the rc file. 234. 235.Sh FILES 236.Bl -tag -width "-c" 237.It Pa @sysconfdir@/zfs/zed.d 238The default directory for enabled ZEDLETs. 239.It Pa @sysconfdir@/zfs/zed.d/zed.rc 240The default rc file for common variables used by ZEDLETs. 241.It Pa @zfsexecdir@/zed.d 242The default directory for installed ZEDLETs. 243.It Pa @runstatedir@/zed.pid 244The default file containing the daemon's process ID. 245.It Pa @runstatedir@/zed.state 246The default file containing the daemon's state. 247.El 248. 249.Sh SIGNALS 250.Bl -tag -width "-c" 251.It Sy SIGHUP 252Reconfigure the daemon and rescan the directory for enabled ZEDLETs. 253.It Sy SIGTERM , SIGINT 254Terminate the daemon. 255.El 256. 257.Sh SEE ALSO 258.Xr zfs 8 , 259.Xr zpool 8 , 260.Xr zpool-events 8 261. 262.Sh NOTES 263The 264.Nm 265requires root privileges. 266.Pp 267Do not taunt the 268.Nm . 269. 270.Sh BUGS 271ZEDLETs are unable to return state/status information to the kernel. 272.Pp 273Internationalization support via gettext has not been added. 274