When you have a server that hosts websites for other people, curious how you track transfer usage per account?
(debian/ubuntu)
|
|
|
Use a tool to generate statistical information from your webserver logs. A good one is AWStats. It can mesure bandwidth usage on a per-website basis. |
|||
|
|
|
Aside from using a package like AWstats, if you're trying to get at the information yourself your only hope is, as nrgyz said, the webserver logs (in particular what are called the "access logs"). You can grok from those logs who's accessing which files, then filter out the user in particular based on directory or some other mechanism, as well as the date-range you're interested in, and create a hash/map structure or something that counts how many time each file was hit and then do the math based on file-size. AWstats works quite well, I use it for a number of customers. There's also Mint and Webalizer (and probably a billion more in freshmeat) |
|||
|
|
|
If you have the luxury of configuring all services for a particular account under it's own IP address then you can use ip accounting in iptables. Setup different chains for each IP and then use a script running from cron to store the results into a rrd (like cacti) or SQL database. The benefit of this approach is you get all traffic for that customer, including web, scp, email, ftp, DDOS attacks, etc. |
|||
|