Re: bandwidth measurement by process

2010-05-10 Thread Mirko Parthey
On Sun, May 09, 2010 at 02:08:15AM -0400, Celejar wrote:
 I'm looking for a tool that will measure bandwidth used by a specific
 process. I'd like some sort of utility or wrapper that will answer
 questions like How much data did my network backup job push over the
 wire?

Check out network namespaces:
http://lxc.sourceforge.net/network/configuration.php

Put your process(es) in a separate network namespace,
set up virtual networking with macvlan or veth,
retrieve the desired statistics from inside this namespace.

Haven't tried it myself yet, though.

Mirko


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: 
http://lists.debian.org/20100510160631.ga30...@titus.informatik.tu-chemnitz.de



bandwidth measurement by process

2010-05-09 Thread Celejar
Hi,

I'm looking for a tool that will measure bandwidth used by a specific
process. I'd like some sort of utility or wrapper that will answer
questions like How much data did my network backup job push over the
wire?

There are many tools that measure by interface / TCP port, etc, but the
only thing I've been able to find that isolates traffic on a per
process basis is nethogs.  I assume that this is tricky, because TCP /
IP traffic doesn't really have the concept of associated processes, and
one needs some method of correlating traffic with processes (nethogs
apparently does this by analyzing various files under /proc).

Are there any other tools out there?  Nethogs is a TUI (ncurses) app
that prints a realtime tally of traffic for every process on the system,
and I'd really like a simple CLI utility that will focus on one specific
process and let me know how much traffic it's generating. I've searched
quite a bit, but found nothing besides nethogs.

Celejar
-- 
foffl.sourceforge.net - Feeds OFFLine, an offline RSS/Atom aggregator
mailmin.sourceforge.net - remote access via secure (OpenPGP) email
ssuds.sourceforge.net - A Simple Sudoku Solver and Generator


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20100509020815.653242ea.cele...@gmail.com



Re: bandwidth measurement by process

2010-05-09 Thread Anand Sivaram
On Sun, May 9, 2010 at 11:38, Celejar cele...@gmail.com wrote:

 Hi,

 I'm looking for a tool that will measure bandwidth used by a specific
 process. I'd like some sort of utility or wrapper that will answer
 questions like How much data did my network backup job push over the
 wire?

 There are many tools that measure by interface / TCP port, etc, but the
 only thing I've been able to find that isolates traffic on a per
 process basis is nethogs.  I assume that this is tricky, because TCP /
 IP traffic doesn't really have the concept of associated processes, and
 one needs some method of correlating traffic with processes (nethogs
 apparently does this by analyzing various files under /proc).

 Are there any other tools out there?  Nethogs is a TUI (ncurses) app
 that prints a realtime tally of traffic for every process on the system,
 and I'd really like a simple CLI utility that will focus on one specific
 process and let me know how much traffic it's generating. I've searched
 quite a bit, but found nothing besides nethogs.

 Celejar
 --
 foffl.sourceforge.net - Feeds OFFLine, an offline RSS/Atom aggregator
 mailmin.sourceforge.net - remote access via secure (OpenPGP) email
 ssuds.sourceforge.net - A Simple Sudoku Solver and Generator


 --
 To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org
 with a subject of unsubscribe. Trouble? Contact
 listmas...@lists.debian.org
 Archive: http://lists.debian.org/20100509020815.653242ea.cele...@gmail.com


 nethogs is unique in that manner, as per their website itself.
http://nethogs.sourceforge.net/
see section Links in their website

Most of the other tools give rate per tcp/udp sessions based on port numbers
and remote address information.
So you may not find any other program to take care of this.  I think it is
doable with a few hundred lines of code.
This is what is required to be done.
* /proc/pid/fd look for the socket inode numbers
* correlate those inode numbers in /proc/net/tcp and /proc/net/udp to find
the
   source and destination ip and port details
* use libpcap to open the interface and capture the packet, from this you
could get the packet length, rate etc of each tcp, udp session
Combining the above, it is possible to get what you need.


Re: bandwidth measurement by process

2010-05-09 Thread Celejar
On Sun, 9 May 2010 12:15:49 +0530
Anand Sivaram aspn...@gmail.com wrote:

 On Sun, May 9, 2010 at 11:38, Celejar cele...@gmail.com wrote:
 
  Hi,
 
  I'm looking for a tool that will measure bandwidth used by a specific
  process. I'd like some sort of utility or wrapper that will answer
  questions like How much data did my network backup job push over the
  wire?

...

  nethogs is unique in that manner, as per their website itself.
 http://nethogs.sourceforge.net/
 see section Links in their website
 
 Most of the other tools give rate per tcp/udp sessions based on port numbers
 and remote address information.
 So you may not find any other program to take care of this.  I think it is
 doable with a few hundred lines of code.
 This is what is required to be done.
 * /proc/pid/fd look for the socket inode numbers
 * correlate those inode numbers in /proc/net/tcp and /proc/net/udp to find
 the
source and destination ip and port details
 * use libpcap to open the interface and capture the packet, from this you
 could get the packet length, rate etc of each tcp, udp session
 Combining the above, it is possible to get what you need.

Yeah, that's pretty much what I thought.  Well, I think that I'm going
to code something like this, unless someone else will point out that
it's already been done.

I'm actually surprised that such a tool doesn't exist.  Isn't this
something quite useful?  Aren't the sorts of questions that I want
answered pretty universal and important?

Celejar
-- 
foffl.sourceforge.net - Feeds OFFLine, an offline RSS/Atom aggregator
mailmin.sourceforge.net - remote access via secure (OpenPGP) email
ssuds.sourceforge.net - A Simple Sudoku Solver and Generator


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20100509030342.8f65db26.cele...@gmail.com



Re: bandwidth measurement by process

2010-05-09 Thread Anand Sivaram
On Sun, May 9, 2010 at 12:33, Celejar cele...@gmail.com wrote:

 On Sun, 9 May 2010 12:15:49 +0530
 Anand Sivaram aspn...@gmail.com wrote:

  On Sun, May 9, 2010 at 11:38, Celejar cele...@gmail.com wrote:
 
   Hi,
  
   I'm looking for a tool that will measure bandwidth used by a specific
   process. I'd like some sort of utility or wrapper that will answer
   questions like How much data did my network backup job push over the
   wire?

 ...

   nethogs is unique in that manner, as per their website itself.
  http://nethogs.sourceforge.net/
  see section Links in their website
 
  Most of the other tools give rate per tcp/udp sessions based on port
 numbers
  and remote address information.
  So you may not find any other program to take care of this.  I think it
 is
  doable with a few hundred lines of code.
  This is what is required to be done.
  * /proc/pid/fd look for the socket inode numbers
  * correlate those inode numbers in /proc/net/tcp and /proc/net/udp to
 find
  the
 source and destination ip and port details
  * use libpcap to open the interface and capture the packet, from this you
  could get the packet length, rate etc of each tcp, udp session
  Combining the above, it is possible to get what you need.

 Yeah, that's pretty much what I thought.  Well, I think that I'm going
 to code something like this, unless someone else will point out that
 it's already been done.

 I'm actually surprised that such a tool doesn't exist.  Isn't this
 something quite useful?  Aren't the sorts of questions that I want
 answered pretty universal and important?

 Celejar
 --
 foffl.sourceforge.net - Feeds OFFLine, an offline RSS/Atom aggregator
 mailmin.sourceforge.net - remote access via secure (OpenPGP) email
 ssuds.sourceforge.net - A Simple Sudoku Solver and Generator


 --
 To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org
 with a subject of unsubscribe. Trouble? Contact
 listmas...@lists.debian.org
 Archive: http://lists.debian.org/20100509030342.8f65db26.cele...@gmail.com


Many of the programs are created when a potential developer felt that he/she
requires such a program, but his/her requirement is not met by the existing
programs.  Now you are feeling that your requirement is not fulfilled and
you are planning to get something of your own :)
Your plan is really good, I could provide any help, in case you require any.


Re: bandwidth measurement by process

2010-05-09 Thread Frederik Kriewitz
On Sun, May 9, 2010 at 9:03 AM, Celejar cele...@gmail.com wrote:
 Yeah, that's pretty much what I thought.  Well, I think that I'm going
 to code something like this, unless someone else will point out that
 it's already been done.

I don't know anything like this, but another approch to to this might
be to use LD_PRELOAD and/or PTRACE to hook connect(), write() and
read().


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: 
http://lists.debian.org/v2xf67028d41005090020kebdb09a5zfe49825b5bfd4...@mail.gmail.com



Re: bandwidth measurement by process

2010-05-09 Thread Anand Sivaram
On Sun, May 9, 2010 at 12:50, Frederik Kriewitz frede...@kriewitz.euwrote:

 On Sun, May 9, 2010 at 9:03 AM, Celejar cele...@gmail.com wrote:
  Yeah, that's pretty much what I thought.  Well, I think that I'm going
  to code something like this, unless someone else will point out that
  it's already been done.

 I don't know anything like this, but another approch to to this might
 be to use LD_PRELOAD and/or PTRACE to hook connect(), write() and
 read().


 --
 To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org
 with a subject of unsubscribe. Trouble? Contact
 listmas...@lists.debian.org
 Archive:
 http://lists.debian.org/v2xf67028d41005090020kebdb09a5zfe49825b5bfd4...@mail.gmail.com


LD_PRELOAD also seems to be a viable option since it is one process
specific.  You may need to include send(), recv() also apart from read(),
write()


Re: bandwidth measurement by process

2010-05-09 Thread Celejar
[Please reply to this list only, and not to me.]

On Sun, 9 May 2010 09:20:36 +0200
Frederik Kriewitz frede...@kriewitz.eu wrote:

 On Sun, May 9, 2010 at 9:03 AM, Celejar cele...@gmail.com wrote:
  Yeah, that's pretty much what I thought.  Well, I think that I'm going
  to code something like this, unless someone else will point out that
  it's already been done.
 
 I don't know anything like this, but another approch to to this might
 be to use LD_PRELOAD and/or PTRACE to hook connect(), write() and
 read().

Thanks.  I had thought of this approach, too, but I have much more
confidence in my being able to correctly code a pcap application
than to mess with preloading.

Celejar
-- 
foffl.sourceforge.net - Feeds OFFLine, an offline RSS/Atom aggregator
mailmin.sourceforge.net - remote access via secure (OpenPGP) email
ssuds.sourceforge.net - A Simple Sudoku Solver and Generator


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20100509124426.92782bbc.cele...@gmail.com



Re: bandwidth measurement by process

2010-05-09 Thread Celejar
On Sun, 9 May 2010 12:49:30 +0530
Anand Sivaram aspn...@gmail.com wrote:

...

  I'm actually surprised that such a tool doesn't exist.  Isn't this
  something quite useful?  Aren't the sorts of questions that I want
  answered pretty universal and important?
 
  Celejar

...

 Many of the programs are created when a potential developer felt that he/she
 requires such a program, but his/her requirement is not met by the existing
 programs.  Now you are feeling that your requirement is not fulfilled and
 you are planning to get something of your own :)
 Your plan is really good, I could provide any help, in case you require any.

I'm not complaining, just surprised.  Anyway, I'm going to do this (or
get really stuck trying ;)) when I get a chance, and I appreciate your
offer of help. If / when I do get stuck, I'll take you up on it!

Celejar
-- 
foffl.sourceforge.net - Feeds OFFLine, an offline RSS/Atom aggregator
mailmin.sourceforge.net - remote access via secure (OpenPGP) email
ssuds.sourceforge.net - A Simple Sudoku Solver and Generator


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20100509125629.49cd6a77.cele...@gmail.com