I'm researching LTTNG with the purpose to gather kernel events from other processes (not by a specific pid, but any process). I have managed to get kernel syscalls for read and write operations, however, the data retrieved there is not quite what i need.
I need to be able to see a live feed for when a process is created (i need the PID, process path and the parent PID), and most important, i need to see whenever a process is performing read/write operations on files (and exactly what those files are).
On Windows i can receive this using ETW tracing. I need the same thing on linux and LTTNG seems to be the closest thing to achieving that from what i've researched.
Did anybody tried to do this before?
Thank you in advance!
Getting the write and read syscall is a good first step!
The
cloneandexecvesyscalls will provide you information regarding the process creation.The
execvesyscall provides the process path.Indeed, it would be nice to have the pid, ppid for each event to ease analysis. This can be done using the
lttng add-contextcommand. For this case:We then get:
I encourage you to take a look at the available context using the
lttng add-context --listcommand.Now onto the read/write/open/close for files, a base event setup would be:
The
openfamily is important since it give the starting point of the relation between the fd number and the file path. Theclosesyscall is important to give you the end of the relation.As for the "live feed", the live mode would fit the bill. But if you can spare some delay, I would encourage you to look into the rotation feature.
From there you should have all the information required. Unfortunately, Trace Compass does not seem to offer a baked-in analysis for this. If you are up to the task, it should not be too hard to implement in a Babeltrace2 python plugin or simply using the python TraceCollection API.
In recap: