
06-14-2005, 06:59 AM
|
|
Web Hosting Master
|
|
Join Date: Feb 2003
Location: Kuala Lumpur, Malaysia
Posts: 4,970
|
|
How is bandwidth measured via apache? Is there any software that can calculate that?
As mentioned, I am requested to build a custom system that does not use any control panel but calculates bandwidth used via httpd (apache)
Any idea how is it measured? Is there any good software that does that?
__________________
Whei Wong
OnApp - www.onapp.com
Cloud and CDN software for the hosters!
|

06-14-2005, 07:23 AM
|
|
Performance Specialist
|
|
Join Date: Dec 2004
Location: New York, NY
Posts: 10,338
|
|
VNStat?
cd /tmp
wget http://humdi.net/vnstat/vnstat-1.4.tar.gz
tar xzf vnstat-1.4.tar.gz
cd vnstat-1.4/
make
make install
vnstat -u -i venet0
If you get an error after that, no worries.
Thanks,
__________________
MediaLayer, LLC - Lightning fast web hosting since 2005. Ask about our new pure SSD storage platform!
›› First and leading provider of LiteSpeed based hosting combined with enterprise grade hardware.
›› Free Account Migrations, Custom Solutions, and Servers in US, EU, and Asia
›› Our Application Hosting plans outperform the typical VPS. Ask us about special offers on yearly plans!
|

06-14-2005, 07:30 AM
|
|
Web Hosting Master
|
|
Join Date: Feb 2003
Location: Kuala Lumpur, Malaysia
Posts: 4,970
|
|
This seems to be total usage. I need a bandwidth calculator that works on individual website like cpanel does. Individual bandwidth usage.
__________________
Whei Wong
OnApp - www.onapp.com
Cloud and CDN software for the hosters!
|

06-14-2005, 08:11 AM
|
|
Junior Guru Wannabe
|
|
Join Date: Jul 2003
Location: Missouri
Posts: 30
|
|
Closest thing out there is mod_throttle which seems to be what your looking for.
|

06-14-2005, 10:41 AM
|
|
Web Hosting Evangelist
|
|
Join Date: Nov 2002
Posts: 510
|
|
Yes.. mod_throttle is the best choice. But you can write something on your own, that would run on daily or hourly basis and make use of the access logs to count the bandwidth usage of a particular site.
It would be something like this:
- Read the access_log file of the site.
- Get all access files.
- Make an array and store all the filenames, in the memory. Make sure that you are able to count the instances of each file so you can multiply later on. We could count the size for each instance but this would be waste of server resources.
- Start counting the file sizes.
- Store the total size you got, somewhere.
- Delete the access log file.
|

06-14-2005, 11:17 AM
|
|
Web Hosting Master
|
|
Join Date: Jan 2003
Location: Lake Arrowhead, CA
Posts: 789
|
|
I disagree that mod_throttle is the best choice because it adds more overhead than stat collection alone (unless you plan to run it already of course).
There are more than a few Apache modules which can do the back end of this (mod_accounting, mod_watch and mod_log_sql are a few more), but if your Apache install is already logging for each VirtualHost, adding a separate accounting module might increase the server's work load unneccesarily. If load is potentially an issue, the best solution may be to replace Apache's internal logging with one of the above modules or write a custom script as Mike_R suggests to parse Apache log files and collect stats on a schedule. The advantage to the latter is that you can schedule your stat collection at times when the server is normally under minimal load.
Since most third-party Apache log parsers are designed for full stats and not just bandwidth, we wrote our own. In concept this is fairly simple: open each log file, read the 7th field of each line (assuming CLF that's bytes) and update a database table for each domain. In practice, however you will want to do things to integrate it into your system and keep it efficient. We read the log file names from an account database, save file position pointers and date information for each log (don't have to delete logs every time the script runs, but never count the same line twice), exclude our own IPs from the collected stats and integrate http, ftp and email counters in one script.
If you don't want to do all that, I would try mod_log_sql or mod_accounting.
|

06-14-2005, 07:28 PM
|
|
Junior Guru
|
|
Join Date: Apr 2005
Location: Sweden
Posts: 241
|
|
If you do decide to parse log files, don't use the file size, the size of the http responce is already in the log file (usually). For dynamically created content, file size and actual amount transferred wont match anyways, so the file size is irrelevant.
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
| Postbit Selector |
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
| Login: |
|
|
| Advertisement: |
|
|
| Web Hosting News: |
|
|
|