Is how I would do it with a cpanel server, that prolly won't work for you, you will need to match something else in the logs to identify where the traffic is going, but still that's how you would do it, load the log file into an array loop over each line matching the request location and status and numbers and then write some if clauses to collect the correct data from the matched data.
If you don't have access to cpanel, or still don't get it, then please take about 20 lines out of the log file you want to parse and post it, and tell me what is identifying each seperate "subdomain"
PHP Code:
<?
function cpanel_logs( $username, $password, $domain, $searchpath )
{
$bw = 0 ;
$logs = file( sprintf( 'http://%s:%s@%s:2082/getlogarchive/%s',
$username,
$password,
$domain,
$domain ));
if( $logs )
{
foreach( $logs as $line )
{
preg_match( '~"([A-Z]+) (.*?[^ ]) HTTP/1\.[1|0]" ([0-9]+) ([0-9]+) "(.*?[^"])" "(.*?[^"])"~si',
$line,
$matches
);
if( ereg( $searchpath, $matches[2] ) )
{
$bw += $matches[4];
}
}
}
return $bw ;
}
$username = 'username';
$password = 'password';
$hostname = 'hostname.com';
printf( 'Images on %s have taken up a total of %01.2fMB bandwidth today<br />',
$hostname,
cpanel_logs( $username, $password, $hostname, 'images' ) / 1048576
);
printf( '%s has taken up a total of %01.2fMB bandwidth today<br />',
$hostname,
cpanel_logs( $username, $password, $hostname, '/' ) / 1048576
);
?>