Bandwidth/traffic stats
Some of them are interested to know what and/or howmuch they have transfered from there site, is there any easy way of tracking this kind of information?
the sites are all virtual hosts in apache2.. so i was thinking is there any kind of traffic accounting module for apache?
cheers
Nathan
6 Replies
cheers
NF
ServerRoot "/www"
LogLevel warn
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
ServerAlias mysite.com
Options +Indexes
ServerAdmin
DocumentRoot /home/mysite/www
CustomLog logs/access_log combined
puts log file in /www/logs/access_log
In Apache config, if it isn't already setup, you'll want to let Apache know to not log virtual hosts to your main log file and also a logformat describing the format to log to for AWStats (my config uses the standard NCSA combined log format, it might already be configured in your Apache config):
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
CustomLog logs/access_log combined env=!VLOG
Then in each of your virtualhost definitions (depending on where you want to see your logs):
CustomLog logs/access_log_myvhost combined
The rest of the setup is croning AWStats to run whenever you want stats updated (the more often the better since AWStats knows where it left off in the log files, and can spread out it's work load, especially if you enable DNS lookups, not advisable on high traffic sites).
In your AWStats config files, the variables you'll want to make sure you've set are:
LogFile="/var/log/apache2/access_log_myvhost"
LogType=W
# Here's where that NCSA standard comes in handy, you
# don't have to specify you're entire custom format since
# AWStats has a setting for the standard.
LogFormat=1
SiteDomain="mydomain.tld"
So long as you have those ones set right, you should be fine, but it's always a good idea to go through the entire config file of course. The important settings should be right up top.
@tierra:
I use AWStats along with separate log files for all my vhosts. You should be able to do it with one log file, but if you miss a configuration option, you're going to get vhost statistics mixed in with other vhosts. There is a big drawback to my setup though. If you have lots of vhosts, this isn't going to work for you, Apache will lock up opening too many file descriptors on log files. With fair warning out of the way…
Yeah, I've run into that before. The good news is that it can handle several hundred open files. If you have an access log, error log, and SSL log for each vhost, you can probably get upwards of about a hundred domains or so before it crashes and burns.
If you only use maybe 20 vhosts, there's no problem at all.
That's also part of the reason I kill logging to the main access log file as well since it would double the file descriptors open with both a separate vhost log file and main access log file.