Re: Fwd: Any way to find the network usage by a process?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Mike Mason <[email protected]> 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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux