3

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

Matt Simmons
  • 20,218
  • 10
  • 67
  • 114
Kevin
  • 63
  • 4
  • 1
    What's a "user" in the context of your question? Like, say, "Evan Anderson" on "ServerFault.com", or, like "ServerFault.com" on a shared hosting provider? – Evan Anderson Oct 26 '09 at 15:55
  • 1
    I strongly disagree with the statement that "all web hosts do this". – womble Oct 26 '09 at 16:04
  • @Evan Anderson - Both! Monitoring users on a website in limited contexts might be useful. My original question is regarding a site on a shared hosting provider. @womble - Every web host I've come across limits your total monthly bandwidth usage. I just figured that they do this by monitoring you somehow. – Kevin Oct 26 '09 at 22:04

2 Answers2

2

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

toppledwagon
  • 4,215
  • 24
  • 15
1

All web hosts do this.

It's my observation that most web hosts don't do this. Most that I've seen record a copy of the logfiles in a (root-owned) directory and check them monthly.

We used ipfm, but now we use ipa.

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

When you buy rate of usage, translating it into cost is dependent on your utilization in addition to your usage.

For example, if you buy a $3000/month DS3, and you're at 85% utilization, your cost is $3000 for 94.55T or about 32$/T, but if you're only at 50% utilization, that's $3000 for 55.61T or about 54$/T.

geocar
  • 2,307
  • 14
  • 10