Possible Duplicate:
How can I monitor bandwidth usage by Virtual Host in Apache on Ubuntu
I'm running an Ubuntu 10.04 server that hosts several domain names. All domains point to the same IP address and use the same network interface. I'm really only concerned with the main domain name such as my-domain1.com
and my-domain2.com
. It should include subdomains such as www.my-domain1.com
with the totals for my-domain1.com
. Is there a tool out there that is configurable to track bandwidth usage on a per-domain name basis?
Edit: I'm not looking for only web usage. I'm looking for all traffic.
There is no way of monitoring traffic for all services using a domain name. You would need to have an IP for each domain name to do that. You could potentially monitor the usage for given services depending on if those services maintain information in requests that preserve the domain name. One such service is a web server doing virtual hosting. Web servers doing virtual hosts need to know the domain name to resolve virtual hosts.
You can use the server logs to determine how much bandwidth you are serving up. A tool like awstats will report the bandwidth served. Incoming bandwidth is not reported, but is usually significantly less the outgoing bandwidth.
The short answer is No you can't do that.
The long answer is, you can in a limited way do it.
Short answer: can't because DNS will resolve the request to an IP address and then the client will connect to the IP. There is no way of telling which hostname it was requesting once DNS has converted it.
Long answer: The HTTP 1.1 protocol requires a "host:" header. i.e. the browser sends the hostname that it is requesting to the web server. This is how a web server knows what website to dish out. This is how virtual hosting is able to work on the same IP address. So, theoretically for HTTP you'd be able to work out how much traffic was going to and coming from each address.
Other network services may have similar features as HTTP. But, again many do not. Therefore, it's only really partially possible.
There are many tools that log HTTP traffic statistics & load for HTTP. I'm not sure which ones can do this per website. e.g. rrdtool may be a good option