From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27909 invoked by alias); 5 Oct 2006 21:22:32 -0000 Received: (qmail 27898 invoked by uid 22791); 5 Oct 2006 21:22:32 -0000 X-Spam-Status: No, hits=-0.3 required=5.0 tests=AWL,BAYES_20,SPF_HELO_PASS,SPF_PASS,UNPARSEABLE_RELAY X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 05 Oct 2006 21:22:27 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11.20060308/8.12.11) with ESMTP id k95LMPG5010030; Thu, 5 Oct 2006 17:22:25 -0400 Received: from pobox.toronto.redhat.com (pobox.toronto.redhat.com [172.16.14.4]) by int-mx1.corp.redhat.com (8.12.11.20060308/8.12.11) with ESMTP id k95LMP3M023312; Thu, 5 Oct 2006 17:22:25 -0400 Received: from touchme.toronto.redhat.com (IDENT:postfix@touchme.toronto.redhat.com [172.16.14.9]) by pobox.toronto.redhat.com (8.12.8/8.12.8) with ESMTP id k95LMPY7019465; Thu, 5 Oct 2006 17:22:25 -0400 Received: from ton.toronto.redhat.com (ton.toronto.redhat.com [172.16.14.15]) by touchme.toronto.redhat.com (Postfix) with ESMTP id D4C81800002; Thu, 5 Oct 2006 17:22:24 -0400 (EDT) Received: from ton.toronto.redhat.com (localhost.localdomain [127.0.0.1]) by ton.toronto.redhat.com (8.13.1/8.13.1) with ESMTP id k95LMOvH025091; Thu, 5 Oct 2006 17:22:24 -0400 Received: (from fche@localhost) by ton.toronto.redhat.com (8.13.1/8.13.1/Submit) id k95LMNER025088; Thu, 5 Oct 2006 17:22:23 -0400 X-Authentication-Warning: ton.toronto.redhat.com: fche set sender to fche@redhat.com using -f To: Mike Mason Cc: jrs@us.ibm.com, Irfan Habib , Linux kernel , SystemTAP Subject: Re: Fwd: Any way to find the network usage by a process? References: <3420082f0610030114o5b44b8ak7797483e02002614@mail.gmail.com> <3420082f0610030114o4c6998en907bccce81d28c59@mail.gmail.com> <452285FD.7010909@us.ibm.com> <45241F7A.5050501@us.ibm.com> From: fche@redhat.com (Frank Ch. Eigler) Date: Thu, 05 Oct 2006 21:22:00 -0000 In-Reply-To: <45241F7A.5050501@us.ibm.com> Message-ID: User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org X-SW-Source: 2006-q4/txt/msg00024.txt.bz2 Mike Mason writes: > Here's a variation of Jose's script that uses the networking tapset > and prints top-like output for transmits and receives. [...] Thanks for posting it to the systemtap wiki. Some minor style suggestions follow: > [...] > ifxmit_p[pid(), dev_name] ++ > ifxmit_b[pid(), dev_name] += length These could be collapsed into a single statistics-aggregate array: # ifxmit[pid(), dev_name] <<< length Then the printing routine would use @count(ifxmit[...]) and @sum(ifxmit[...]) to extract the two values. Same of course for ifrecv. > execname[pid()] = execname() > user[pid()] = uid() > ifdevs[pid(), dev_name] = dev_name Calling pid() so many times is worse than calling it once and caching the result in a local variable ("p = pid()"). The way that the script tracks pid-to-uid and pid-to-execname mappings is not bad, though if that part were moved to new probes on fork or exec, it would allow the network-related probes to run concurrently on an SMP without fighting over locks. - FChE