Getting Traffic Size in Bytes from W3C Extended Format Log 
Author Message
 Getting Traffic Size in Bytes from W3C Extended Format Log

Hello Again,

I posted earlier this week about something entirely different and got 4 very
helpful replies.  Hopefully some Perl gurus can help me out of a jam again.
(Godzilla, if you're reading, I used your help on finding the docroot in a
conf file and it worked like a charm... thank you)

I am relatively new to Perl and have the task of obtaining traffic in bytes
from a W3C extended log file.  I have searched for the past 2 hours on
google groups and have not found anything helpful.  I would appreciate any
help in performing this function.  Assuming I have the log file open and in
a format such as:

#Software: Microsoft Internet Information Server 4.0
#Version: 1.0
#Date: 2002-09-07 00:38:31
#Fields: date time c-ip s-sitename cs-method cs-uri-stem cs-uri-query
sc-status sc-bytes cs-bytes s-port cs(User-Agent) cs(Referer)
2002-09-07 01:29:56 10.10.10.10 W3SVC164 GET /checkernt.pl - 404 623 549 80
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1) -
2002-09-07 01:30:21 10.10.10.10 W3SVC164 GET /cgi-bin/checkernt.pl - 200 420
557 80 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1) -

how do I determine the total traffic in bytes?  I have a routine to do this
with analog but can find none out there for W3C Extended format.

I appreciate any input on this issue.  I hope to some day return the favor
to the forums once I've gained some more knowledge myself.

Best Regards,

Tom



Wed, 23 Feb 2005 04:49:50 GMT  
 Getting Traffic Size in Bytes from W3C Extended Format Log
Also sprach Tom P.:

Quote:
> I am relatively new to Perl and have the task of obtaining traffic in bytes
> from a W3C extended log file.  I have searched for the past 2 hours on
> google groups and have not found anything helpful.  I would appreciate any
> help in performing this function.  Assuming I have the log file open and in
> a format such as:

> #Software: Microsoft Internet Information Server 4.0
> #Version: 1.0
> #Date: 2002-09-07 00:38:31
> #Fields: date time c-ip s-sitename cs-method cs-uri-stem cs-uri-query
> sc-status sc-bytes cs-bytes s-port cs(User-Agent) cs(Referer)
> 2002-09-07 01:29:56 10.10.10.10 W3SVC164 GET /checkernt.pl - 404 623 549 80
> Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1) -
> 2002-09-07 01:30:21 10.10.10.10 W3SVC164 GET /cgi-bin/checkernt.pl - 200 420
> 557 80 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1) -

> how do I determine the total traffic in bytes?  I have a routine to do this
> with analog but can find none out there for W3C Extended format.

I suspect that the total traffic for each request is sc-bytes +
cs-bytes, right? Also, one entry in the logfile is one long line, I
hope. In this case it is quite easy:

    open LOG, "/path/to/logfile" or die $!;
    my $total;
    while (<LOG>) {
        $total += $_ for (split)[8,9];
    }

All the above does is running through the log-file linewise, splitting
on whitespace and on the fly adding the 9th and 10th element of this
list to $total. It uses a slice for that.

Tassilo
--

pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;



Wed, 23 Feb 2005 07:45:56 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Perl script to merge access/referrer/agent Common Logs to Extended Log format?

2. Parsing the "extended" HTTP log

3. Image Size in Bytes

4. Increasing hash value size beyond 1024 bytes in DBMs

5. More Perlish file size (bytes, KB, MB)

6. Byte Size of a Scalar -- How?

7. Socket size in bytes

8. size in bytes of a scalar

9. Net::FTP - getting only the first x bytes of a file

10. Getting one byte at a time

11. uploading but getting 0 bytes

12. Getting next byte of scalar

 

 
Powered by phpBB® Forum Software