Measuring bytes of packet sent from python application
aleksandr.goretoy at gmail.com
Tue Jan 6 04:00:01 CET 2009
You can alot run "lsof -i -T -n" from popen2 to see what applications use
what port and addr they are connected to.
In order to see all jobs though it needs to be ran as root. This way you can
find out what ports and such Then perform tcp dump thru popen2 and filter
for port and addr. This is just a first shot, then I would figure out what
to do after having gotten to this point.
#find out what ports and addrs what program is connected to
r,w,e=popen2.popen3("lsof -i -T -n") # this may need sudo prepended to lsof
#get tcpdump, doesn't quiet work here....needs something more, maybe a
different way altogether.
#tcpdump to pcap file and read file periodically?
r1,w1,e1=popen2.popen3("sudo tcpdump -i eth1")
Something to this nature, then do regular expression on tcpdump output,
either logged to pcap output file or by other means.
somebodywhocarez at gmail.com
On Mon, Jan 5, 2009 at 8:14 PM, Grant Edwards <grante at visi.com> wrote:
> On 2009-01-05, Kangkook Jee <aixer77 at gmail.com> wrote:
> > I'd like to measure number of bytes sent(or recv'd) from my
> > python application. Does anyone have any idea how can I
> > achieve this?
> Aside from tcpdump/wireshark, you can set up iptables rules to
> enable accounting for traffic based on IP addresses and ports.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list