Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Jun 2002 21:57:04 +0930
From:      Wincent Colaiuta <wincentcolaiuta@mac.com>
To:        freebsd-isp@FreeBSD.ORG
Subject:   Re: Bandwidth billing and measurement scripts
Message-ID:  <DD446E42-837F-11D6-A68D-003065C60B4C@mac.com>
In-Reply-To: <MBEKKDFNOOOCNGBGIOMHEEKCGFAA.bambi@Hughes.com.au>

index | next in thread | previous in thread | raw e-mail

El Wednesday, 19 June, 2002, a las 03:10  PM, David J. Hughes escribió:

> If you really need to do this for true volume numbers (rather than just 
> the
> info you can glean from the log files) you could run a proxy in front of
> your web server(s) (i.e. a reverse proxy, or distributor,  or whatever 
> your
> terminology dictates) and assign each virtual host a distinct private IP
> address.  In effect you allow the proxy box to act as an HTTP 1.1 to 
> HTTP
> 1.0 gateway.  Do your traffic accounting based on the private IP's 
> (using
> ipfw on the proxy box or whatever method you choose) and your problem is
> solved. I'm not saying I'd do it but it would give you what you are 
> looking
> for (i.e. real IP accounting on 1.1 virtual hosts).

Thankyou David (and others on this list) for the helpful responses. So 
far no one has given me exactly what I was after, and after a thorough 
search of freshmeat.net it is looking as though I will end up coding 
this thing myself.

Because I want this thing to be stable, robust, and dependable enough to 
use as a reliable platform for billing, a design goal would be to build 
it out of simple, well-tested tools that are already present in a 
standard FreeBSD install. So we're talking here a collection of Perl and 
Bourne shell scripts interacting with ipfw and using dbm and perhaps 
some flat files for data storage, all driven by cron.

What I'd like it to do:
- run as an hourly cron job
- count incoming and outgoing bandwidth user per IP based on ipfw 
"count" rules - this should give a totally accurate traffic count 
without the need to resort to parsing mail, http and ftp logs (which 
could get very messy)
- measure % of traffic accounted for http, ftp, mail and "other" (an 
interesting statistic, but not really a useful one, seeing as in the end 
the customer has to pay for it all anyway)
- save ipfw output to disc for safe keeping
- update usage totals per customer in the dbm database: daily and 
monthly totals
- when customer hits bandwidth quota for the month, send a warning email
- when customer exceeds bandwidth quota by 25% or more, account 
temporarily suspended (browser redirected to an explanatory page using 
mod_rewrite), send customer notification email
- generate simple HTML pages showing usage
- provide an easy mechanism for adding/removing hosts/customers to/from 
the accounting system
- able to administer from the shell or from a web-interface

We choose to implement these last couple of somewhat draconian measures 
because here in Australia bandwidth is not cheap (about 20c/meg, 
incoming). We want to avoid any ugly situations where a customer manages 
to get slashdotted (or whatever) and finds themself with a horrid 
bandwidth bill (remember, here in Australia, bandwidth will cost them 
about $200/gig thanks to our monopoly telecommunications supplier, 
Telstra). We figure it's better to temporarily suspend the off account 
here and there than to have customers running up large bills that they 
later refuse to pay (or whatever). If they are pushing out so much data 
that they exceed their quote then they should be on a higher-volume 
plan, or host their site in the US...

In any case, any further suggestions appreciated, but will send to the 
list a link to whatever I end up devising.

Cheers
Wincent


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-isp" in the body of the message



help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?DD446E42-837F-11D6-A68D-003065C60B4C>