Web Hosting Talk







View Full Version : Bandwidth Monitoring Per Domain


orsm
07-01-2003, 09:31 AM
Gday guys,

I've spent the last couple of days searching everywhere I could possibly think of for a way that will allow me to monitor bandwidth usage per domain.

From what I've read it can be done relatively easily with MRTG but that'll only allow me to monitor traffic across individual IP's... doesn't really suit as I have numerous domains sharing single IP's. Basically just need a break down of monthly and maybe daily usage for each domain. Monitoring of hits, referers etc is trivial. I'm more interested in the total usage so once again stuff like graphs etc arent necessary.

From memory Ensim has [or at least had] a tool that does this which would probably suit my needs perfectly but I'm not prepared to run Ensim on the machines.

The servers are linux and can get extremely busy so anything that sucks TONNES of resources and takes forever to process figures probably isnt a good idea.

So... does anyone have any suggestions on how I may go about doing this?

Look forward to your replies and thanks. :)


Orsm.

Slidey
07-01-2003, 09:36 AM
is this just for http?

orsm
07-01-2003, 09:41 AM
Sorry yep... particularly just for HTTP only. If theres a way to monitor both individually then even better I guess.



Orsm.

Slidey
07-01-2003, 09:43 AM
webalizer

orsm
07-01-2003, 09:47 AM
Have been led to believe that Webalizer isnt all that acurate...

Comments?


Orsm.

heyzuess
07-01-2003, 10:10 AM
check this out: http://www.snert.com/Software/mod_watch/

works great for name based virtual servers.

orsm
07-01-2003, 10:37 AM
mod_watch looks decent... has anyone tried running this with 1.3? The page suggests it is only for Apache 2.0.

heyzuess
07-01-2003, 10:43 AM
whoops - try this one: http://www.snert.com/Software/mod_watch-3.18/

JasonBD
07-01-2003, 12:13 PM
I say you make your own php bandwidth script to calculate the kb sent in the apache access logs or your traffic logs. That is what we did it works...

euselect
07-01-2003, 06:25 PM
Hello

I use a combination of webalizer and then a php/shell script to extract the totals from it daily just after webalizer has been run. All this goes into a db after.

Works well for me , if you want a copy let me know.

Neil

euselect
07-02-2003, 02:24 PM
For everyone who asked !

http://www.namx.co.uk/webgrab.tar.gz

A few notes about this:

These scripts are designed to be exexcute in the shell.
They are not intended for execution on webservers thru apache , but could be adapted easily.

You will need to edit at least grab.php, and set the correct path or URL in the line starting: $url=

You will see 2 example entries comment.

You will need a mysql database connect in a file called db.php,

Heres the contents of db.php

<?
// db connection details
////////////////////////
//error_reporting(0);

$db_server = "YOURMYSQLSERVERNAME.com";
$db_user = "YOURMYSQLUSER";
$db_pass = "YOURMYSQLPASS";
$database = "YOURMYSQLDB";

// connect to our db
/////////////////////

if (!($mysql_link = mysql_connect("$db_server", "$db_user", "$db_pass")))
{
// change this print to a syslog eventually !
print ("Could not use $database database, exiting");
exit;
}

if (!(mysql_select_db("$database", $mysql_link)))
{
// change this print to a syslog eventually !
print ("No Mysql service available, exiting");
exit;
}
?>


and a table within the db called websites.

Here is an sql statement to do that ,assuming you have a db already

CREATE TABLE websites (
primary_domain varchar(128) NOT NULL default '',
transfer_used float NOT NULL default '0',
UNIQUE KEY primary_domain (primary_domain)
) TYPE=MyISAM;

Good luck - icq 81854162 if you need help