filetrace-agent as a service for the system’s init: a systemd unit, an OpenRC script or a SysV init script. The agent collects continuously from boot, so the commands always have history to answer from. This guide covers managing the service, configuring it, reading its logs, and controlling who may query it.
Start and stop
- systemd
- OpenRC
- SysV init
--no-start.
filetrace agent status reports the state of the agent behind the socket, whichever way it was started:
0 when the agent runs, 4 when it is stopped, and 9 when it is degraded, for example because it is losing events. filetrace agent stop asks the running agent to stop. Under a service manager, stop the service with the service manager instead.
Configure the agent
The agent reads/etc/filetrace/config.toml once, when it starts. Edit the file, check it, then restart the service:
filetrace config validate exits with 6 and says what is wrong when the file is not usable. An unknown setting or a value of the wrong kind is an error; a setting this build cannot honour is a warning. filetrace config show prints every setting with the value in effect. See the configuration reference.
Settings belong in the configuration file. Command-line options of filetrace-agent override it and can be passed through the service manager when needed:
For example, a systemd drop-in that forces the kprobe set:
filetrace-agent that systemctl cat filetrace-agent shows.
Read the logs
The agent logs to standard error at the level set by[agent] log_level (error, warn, info or debug).
Restart behavior
The systemd unit restarts the agent on failure after 5 seconds, at most 5 times in 5 minutes. It does not restart on exit codes that a retry cannot fix:2 (invalid arguments), 3 (permission denied), 5 (unsupported platform or kernel) and 6 (invalid configuration). The unit only starts when /sys/kernel/btf/vmlinux exists; the OpenRC script checks the same and validates the configuration before it starts the agent.
Control who may query the agent
The agent listens on/run/filetrace/agent.sock. It checks the credentials of every client and answers only root and the user the agent runs as. It closes the connection of any other client and logs rejected a client that is neither root nor the agent's user. Because the packaged service runs as root, use sudo for the commands that query it.
The gRPC API applies the same rule on a unix: socket. On a TCP address it admits anyone who can connect, and the agent says so when it starts. See Security.
Systemd hardening
The unit runs the agent with only the capabilities it needs and a restricted view of the system:Upgrades
The command and the agent speak one protocol version, so a package upgrade restarts a running agent, provided the configuration file is valid for the new version. Otherwise the agent keeps running the old version and the package manager prints whatfiletrace config validate reports; fix the file and restart the service. History starts again with every restart.