Monthly Bandwidth Monitoring/Tracking


Does anyone out there have any experience with bandwidth tracking / monitoring?

Imagine a web server that is allotted a certain amount of bandwidth per month. That server hosts a number of different web sites (aka apache virtual servers), and needs to keep track of how much bandwidth each web site uses so it can either (a) charge individual websites for going over their monthly limit or (b) shut down their website when it goes over a certain limit.

I’ve been looking into a number of different solutions for this situation, and most of the information I can find through Google is … absurd. People suggest everything from installing bloated administrative control panels that do way more than I need, to upgrading to the Zeus web server (not free).

The two ideas I’ve come across that I thought might work are:

1. Custom Apache Module: I found this module that creates it’s own byte-log and shuts down apache service when it goes over a daily limit. This could be modified to work on a monthly basis and update some other external source that could be checked by a web-interface – and customers could be warned *before* problems arise.

2. Apache Log Parsing: I could write a program that works like webalizer, and simply parses apache access logs to determine bandwidth usage. It could run on a cron every night/hour/whatever and update a database with the results.

Does anyone else have any experience with this type of thing. Suggestions?