This is probably best done through apache with a combination of the mod_log_config module and mod_logio module that is available in Apache 2.0.x.
You haven't mentioned how you will identify your clients, but it will probably be done with a REFERER header (easily spoofed by end users) or a cookie or query parameter. Either way, you can use the above modules to generate a custom log to track actual bandwidth used.
Something like the following:
LogFormat "%V %a %s %I %O %{Referer}i %q" trackbandwidth CustomLog /var/log/bandwidth trackbandwidth
You will have to choose what you save in the log file, whether it is the cookie headers, or the query string (this will depend on how you plan to identify your clients). The important entries above are the %I and %O which contain the actual number of bytes sent and received for this request (this includes the headers and the content of the request). I am pretty sure that this will take into consideration a user stopping the request part way through the download as well, but I would suggest you test that before taking my word for it.
Then just write a perl script to parse this log file and generate a full report of the bandwidth used per client.
In reply to Re: Tracking bandwidth
by cees
in thread [untitled node, ID 326674]
by Samn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |