Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

When you have a server that hosts websites for other people, curious how you track transfer usage per account?

(debian/ubuntu)

share|improve this question
add comment

3 Answers

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.

share|improve this answer
add comment

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)

share|improve this answer
add comment

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.

share|improve this answer
    
Here's a perl script for dumping web bandwidth summaries into cacti: cacti.net/downloads/scripts/iptables.pl.txt –  Weston Dec 10 '09 at 20:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.