[mod_python] Using mod_python to track bandwidth

Edward Muller edwardam at interlix.com
Thu Jul 1 17:49:58 EDT 2004


On Thu, 2004-07-01 at 13:56, Edward Muller wrote:
> I'm trying to figure out a way to use mod_python to track the bandwidth
> a site uses. I've figured out how to get the content length of a request
> pretty easily, but I'd also like to be able to also get the length of
> the incoming request and the outgoing headers. I've played around with a
> few different things and can't seem to find any way to get the last two.
> I'm probably missing something so any help would be appreciated.
> 
> Thanks,

Another odd thing I've run into with the following code (run as a
PythonLogHandler):

def log(req):
        f = open('/var/www/apache2-default/out.txt','a')
        con = req.connection
        con_data = con.read(-1)

        f.write("""
Log
hn: %s - bs: %s - cl: %s - rl: %s
--- Connection Data -- len(%s) ---
%s
""" % (  req.hostname,
         req.bytes_sent,
         req.clength,
         req.read_length,
         len(con_data),
         con_data))
        f.close()
        return apache.OK

When I hit a site with Firefox/Mozilla con_data contains all the
incoming headers, but when I wget the same data con_data is empty.


-- 
Edward Muller - http://www.interlix.com - "Open Source Specialists"
Dedicated Zope Hosting - Web Hosting - Open Source Consulting
Network & PC Service & Support - Custom Programming
Phone: 417-862-0573 - Cell: 417-844-2435 - Fax: 417-869-3137
Jabber: edwardam at jabber.interlix.com - AIM: edwardam453 - ICQ: 287033



More information about the Mod_python mailing list