From owner-freebsd-isp Wed Jun 19 5:27:43 2002 Delivered-To: freebsd-isp@freebsd.org Received: from smtpout.mac.com (smtpout.mac.com [204.179.120.89]) by hub.freebsd.org (Postfix) with ESMTP id 7D8D237B408 for ; Wed, 19 Jun 2002 05:27:33 -0700 (PDT) Received: from smtp-relay.mac.com (smtp-relay01-en1 [10.13.10.224]) by smtpout.mac.com (8.12.1/8.10.2/1.0) with ESMTP id g5JCRWkv013472 for ; Wed, 19 Jun 2002 05:27:32 -0700 (PDT) Received: from asmtp02.mac.com (asmtp02-qfe3 [10.13.10.66]) by smtp-relay.mac.com (8.12.1/8.12.1/1.0) with ESMTP id g5JCRQrE012464 for ; Wed, 19 Jun 2002 05:27:27 -0700 (PDT) Received: from localhost ([202.45.118.117]) by asmtp02.mac.com (Netscape Messaging Server 4.15) with ESMTP id GXYD9P00.M5G for ; Wed, 19 Jun 2002 05:27:25 -0700 Date: Wed, 19 Jun 2002 21:57:04 +0930 Subject: Re: Bandwidth billing and measurement scripts Content-Type: text/plain; charset=ISO-8859-1; format=flowed Mime-Version: 1.0 (Apple Message framework v482) From: Wincent Colaiuta To: freebsd-isp@FreeBSD.ORG Content-Transfer-Encoding: quoted-printable In-Reply-To: Message-Id: X-Mailer: Apple Mail (2.482) Sender: owner-freebsd-isp@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org El Wednesday, 19 June, 2002, a las 03:10 PM, David J. Hughes escribi=F3: > If you really need to do this for true volume numbers (rather than = just=20 > 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=20= > 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=20= > HTTP > 1.0 gateway. Do your traffic accounting based on the private IP's=20 > (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=20 > looking > for (i.e. real IP accounting on 1.1 virtual hosts). Thankyou David (and others on this list) for the helpful responses. So=20= far no one has given me exactly what I was after, and after a thorough=20= search of freshmeat.net it is looking as though I will end up coding=20 this thing myself. Because I want this thing to be stable, robust, and dependable enough to=20= use as a reliable platform for billing, a design goal would be to build=20= it out of simple, well-tested tools that are already present in a=20 standard FreeBSD install. So we're talking here a collection of Perl and=20= Bourne shell scripts interacting with ipfw and using dbm and perhaps=20 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=20 "count" rules - this should give a totally accurate traffic count=20 without the need to resort to parsing mail, http and ftp logs (which=20 could get very messy) - measure % of traffic accounted for http, ftp, mail and "other" (an=20 interesting statistic, but not really a useful one, seeing as in the end=20= 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=20 monthly totals - when customer hits bandwidth quota for the month, send a warning email - when customer exceeds bandwidth quota by 25% or more, account=20 temporarily suspended (browser redirected to an explanatory page using=20= mod_rewrite), send customer notification email - generate simple HTML pages showing usage - provide an easy mechanism for adding/removing hosts/customers to/from=20= 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=20= because here in Australia bandwidth is not cheap (about 20c/meg,=20 incoming). We want to avoid any ugly situations where a customer manages=20= to get slashdotted (or whatever) and finds themself with a horrid=20 bandwidth bill (remember, here in Australia, bandwidth will cost them=20 about $200/gig thanks to our monopoly telecommunications supplier,=20 Telstra). We figure it's better to temporarily suspend the off account=20= here and there than to have customers running up large bills that they=20= later refuse to pay (or whatever). If they are pushing out so much data=20= that they exceed their quote then they should be on a higher-volume=20 plan, or host their site in the US... In any case, any further suggestions appreciated, but will send to the=20= 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