From: Mike Mason <mmlnx@us.ibm.com>
To: "Frank Ch. Eigler" <fche@redhat.com>
Cc: jrs@us.ibm.com, Irfan Habib <irfan.habib@gmail.com>,
Linux kernel <linux-kernel@vger.kernel.org>,
SystemTAP <systemtap@sources.redhat.com>
Subject: Re: Fwd: Any way to find the network usage by a process?
Date: Thu, 05 Oct 2006 16:28:10 -0700 [thread overview]
Message-ID: <4525950A.8020009@us.ibm.com> (raw)
In-Reply-To: <y0m3ba2jw4w.fsf@ton.toronto.redhat.com>
Frank Ch. Eigler wrote:
> Mike Mason <mmlnx@us.ibm.com> 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.
I tried that and got the following output:
PID UID DEV XMIT_PK RECV_PK XMIT_KB RECV_KB COMMAND
0 0 eth0 9 10 486 672 swapper
ERROR: empty aggregate near identifier 'execname' at nettop.stp:35:4
WARNING: Number of errors: 1, skipped probes: 0
Apparently using @sum on empty aggregates isn't allowed. I expected 0's to
be returned. The only way to avoid the error is use @sum only if @count >
0, which makes the printf too complex in my opinion.
>
>> 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()").
Agreed. I'll change that.
>
> 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.
But that would only catch processes created after the script starts, correct?
- Mike
>
>
> - FChE
prev parent reply other threads:[~2006-10-05 23:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <3420082f0610030114o5b44b8ak7797483e02002614@mail.gmail.com>
2006-10-03 8:14 ` Fwd: Any way to find the network usage by a process? Irfan Habib
2006-10-03 15:33 ` Arnd Hannemann
2006-10-03 15:47 ` Jose R. Santos
2006-10-04 20:54 ` Mike Mason
2006-10-05 21:22 ` Frank Ch. Eigler
2006-10-05 23:28 ` Mike Mason [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4525950A.8020009@us.ibm.com \
--to=mmlnx@us.ibm.com \
--cc=fche@redhat.com \
--cc=irfan.habib@gmail.com \
--cc=jrs@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=systemtap@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox