Fwd: Any way to find the network usage by a process?
Mike Mason
mmlnx@us.ibm.com
Fri Oct 6 01:10:00 GMT 2006
Frank Ch. Eigler wrote:
> Hi -
>
> On Thu, Oct 05, 2006 at 04:28:10PM -0700, Mike Mason wrote:
>> [...]
>> 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.
>
> As a judgement call, to be consistent with other extractors like @avg,
> the @sum etc. of an empty set was deemed to be undefined.
>
>> The only way to avoid the error is use @sum only if @count >
>> 0, which makes the printf too complex in my opinion.
>
> Maybe so. It's worth considering some syntactic sugar to express a
> undefined=>0 intent.
Actually, the following works fine and doesn't complicate it too much:
foreach ([pid, dev] in ifpid-) {
n_xmit = @count(ifxmit[pid, dev])
n_recv = @count(ifrecv[pid, dev])
printf("%5d %5d %-7s %7d %7d %7d %7d %-15s\n",
pid, user[pid], dev, n_xmit, n_recv,
n_xmit ? @sum(ifxmit[pid, dev])/1024 : 0,
n_recv ? @sum(ifrecv[pid, dev])/1024 : 0,
execname[pid])
}
I'll update the wiki page. Thanks for the suggestions.
- Mike
More information about the Systemtap
mailing list