How to monitor total outgoing bandwidth usage on a per-user basis

apache-2.2bandwidthmonitoringusage

How does one monitor total outgoing bandwidth usage on a per-user basis?

(I'm using apache 2.2 in case you need this information.)

All web hosts do this. So it would seem obvious, but I can't find any information on how to do this. Even a partial answer would help.

Remember, I don't care about the user's rate of usage, only their total bandwidth usage.

Thanks, Kevin

Best Answer

You need to parse the logs with a custom script. You'll also likely want a custom log format (to capture the VirtualHost names.) You can either parse the logs daily (or hourly/weekly) or you can run the logs through a script as it happens.

LogFormat "%B \"%{Host}i\"" myformat
CustomLog "|/usr/local/bin/apachebwmeter" myformat

It's up to you to write /usr/local/bin/apachebwmeter. Make sure to coalesce the domain names (www.example.com and example.com are the same user, you might have other variations depending on your environment.) Keep in mind that %B does NOT include HTTP headers, so it'll be approximate.

-Dave

Related Topic