I need to get some statistic(io, network) of a process during its lifetime. Is there anyway to get those information from /proc just before the process exit ? Linux Kernel API ?
相关问题
- Is shmid returned by shmget() unique across proces
- how to get running process information in java?
- Error building gcc 4.8.3 from source: libstdc++.so
- Why should we check WIFEXITED after wait in order
- Null-terminated string, opening file for reading
wait4()
andstruct rusage
A simple way to gather some statistics after child process termination is
wait4(2)
syscall, which can fillrusage
struct.ptrace()
If it's not enough, you can probably use
ptrace(2)
to stop a process just before its termination:When
waitpid(2)
will report that process is going to terminate and stopped, you can gather statistics from/proc
, but I didn't try this.KProbes
The most generic solution I know is
KProbes
and derivatives. You can probably use DTrace or SystemTap to trapsys_exit()
and gather statistics.