network bitrate of a poll of processes

Jeremie Le Hen jeremie at le-hen.org
Sat Jun 7 21:52:19 UTC 2008


Hi Mathieu,

On Mon, May 26, 2008 at 04:52:04PM +0200, Mathieu Prevot wrote:
> I would like to know the bitrate of a pool of child processes that use
> a network connection, how can I have something like netstat -w1
> provide but at the process level ?

One way to do it is to create a dynamic library providing a wrapper for
read/write/send/recv/whichever syscalls that counts the number of bytes.
Use gettimeofday(2) in a construtor and destructor to print the average
bitrage.  At runtime, load the shared library with LD_PRELOAD.

If you want real time bitrate, I think you need an external 
device or you may spoil the results.

Regards,
-- 
Jeremie Le Hen
< jeremie at le-hen dot org >< ttz at chchile dot org >


More information about the freebsd-hackers mailing list