How Do Blog Metrics

| No Comments

You may have noticed a new link on the right side of the page labelled How about some analytics? I wrote something to generate the page and have pasted the code after the flip.


use CGI;
use CGI::Carp;
use strict;
use warnings;
use diagnostics;

open LOG,'/var/log/hasandiwan.info-access_log' or die "$!\n";
my $cgi = new CGI;
print $cgi->header, $cgi->start_html('Analytics of my blog traffic'), $cgi->start_table, $cgi->Tr({-align=>'center', -valign=>'top'}, [$cgi->th(['IP Address','Date','URL Accessed'])]);
my @line = [];
while (my $line = ) {
    push @line,$line;
}
foreach my $line (@line) {
    my @parts = split /\s+/, $line;
    next unless $parts[6];
    next if $parts[0] =~ /^192\.168/ or $parts[6] !~ /(ml)$/;
    $parts[3] = $1 if $parts[3] =~ s/\[(.*)/$1/g;
    print $cgi->Tr({-align=>'center'}, [$cgi->td(["$parts[0] ", "$parts[3] Pacific Time", "$parts[6]"])]);
}
print $cgi->end_table,$cgi->end_html;

Leave a comment

Bookmark and Share

Connect with me


qrcode
Add me on AOL
Hasan Diwan

Follow me on Twitter
Ring me at +1 6502844111
See my photos
How about some analytics?

Twitter

Archives

Creative Commons License
This blog is licensed under a Creative Commons License.