From owner-freebsd-hackers@FreeBSD.ORG Sat Jun 7 21:52:19 2008 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5BAEE106566C for ; Sat, 7 Jun 2008 21:52:19 +0000 (UTC) (envelope-from tataz@tataz.chchile.org) Received: from postfix2-g20.free.fr (postfix2-g20.free.fr [212.27.60.43]) by mx1.freebsd.org (Postfix) with ESMTP id 1E8778FC0A for ; Sat, 7 Jun 2008 21:52:19 +0000 (UTC) (envelope-from tataz@tataz.chchile.org) Received: from smtp5-g19.free.fr (smtp5-g19.free.fr [212.27.42.35]) by postfix2-g20.free.fr (Postfix) with ESMTP id 7151A271E0B8 for ; Sat, 7 Jun 2008 21:32:44 +0200 (CEST) Received: from smtp5-g19.free.fr (localhost.localdomain [127.0.0.1]) by smtp5-g19.free.fr (Postfix) with ESMTP id 6E7CC3F62CE; Sat, 7 Jun 2008 23:33:06 +0200 (CEST) Received: from tatooine.tataz.chchile.org (tataz.chchile.org [82.233.239.98]) by smtp5-g19.free.fr (Postfix) with ESMTP id 5BEE93F62CC; Sat, 7 Jun 2008 23:33:06 +0200 (CEST) Received: from obiwan.tataz.chchile.org (unknown [192.168.1.25]) by tatooine.tataz.chchile.org (Postfix) with ESMTP id D714D9B497; Sat, 7 Jun 2008 21:29:20 +0000 (UTC) Received: by obiwan.tataz.chchile.org (Postfix, from userid 1000) id C18B94089; Sat, 7 Jun 2008 23:29:20 +0200 (CEST) Date: Sat, 7 Jun 2008 23:29:20 +0200 From: Jeremie Le Hen To: Mathieu Prevot Message-ID: <20080607212920.GN13704@obiwan.tataz.chchile.org> References: <3e473cc60805260752o2f573cf2h12910a45cf6849e6@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3e473cc60805260752o2f573cf2h12910a45cf6849e6@mail.gmail.com> User-Agent: Mutt/1.5.15 (2007-04-06) Cc: hackers@freebsd.org Subject: Re: network bitrate of a poll of processes X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Jun 2008 21:52:19 -0000 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 >