Skip to main content
Both programs report their outcome through the exit code, so that scripts, monitoring checks and service managers can act on it without parsing text. This page lists the codes of the filetrace commands, the special meanings that doctor, agent status and stats give them, and the codes of filetrace-agent with the ones its systemd unit does not restart on. Code 9 deserves the most attention: the command succeeded, but its answer may be incomplete.

filetrace commands

Errors are written to standard error. A usage error (code 2) ends with a pointer to the command’s help:

3: permission denied

The agent’s socket admits only root and the agent’s own user. With the agent running as root, the commands that query it need sudo:

4: agent unavailable

The message names the socket and the reason the connection failed:
filetrace watch and filetrace events --follow do not fail this way: without an agent they collect in the foreground for as long as they run.

5: unsupported

Besides an unsupported kernel or platform, code 5 answers a question this build cannot answer. --method splice, --method mmap and --method io_uring are accepted by files and transfers and refused with code 5, rather than answered with an empty list that would read as “nothing was sent this way”:

6: invalid configuration

Every command except config and help reads the configuration file first, and stops with code 6 when the file cannot be read or does not parse. filetrace config validate reports the problem; it exits with 0 when the file is usable and 6 when it is not. See Configuration file reference.

9: partial results

Code 9 means the command printed its answer, but events were lost inside the queried time range, so byte counts or records may be missing. The output on standard output is complete and well-formed in every format; the warning goes to standard error:
A transfer during which events were lost is marked incomplete: true in JSON and with * after its confidence in tables. Lost events are also counted by watch, stats and doctor. filetrace events --follow exits with 0 when it is interrupted, whatever was lost while it ran.

Commands with their own meanings

doctor

filetrace doctor exits with the code of its verdict, also printed as STATUS: and, with --json, as status:

agent status

stats

filetrace stats exits with 9 while the agent reports recent event loss, that is, a loss within the last minute. The JSON output shows the same condition as "status": "degraded".

filetrace-agent

filetrace-agent and filetrace agent run exit with these codes: The systemd unit restarts the agent on failure after 5 seconds, at most 5 times in 300 seconds, except on the codes that a retry does not fix:
The unit starts only where /sys/kernel/btf/vmlinux exists. Under OpenRC, the service checks for BTF and runs filetrace config validate before every start, and respawns the agent after 5 seconds, at most 5 times in 300 seconds. See Run the agent as a service.

Scripting

Treat 9 as a result to keep, with a warning, rather than as a failure:
A health check that tells a stopped agent from a degraded one:
Use Filetrace output in scripts has more patterns.