Article View: best.general
Article #181Post migration log formats
From: Joe Smith
Date: Fri, 02 Nov 2001 07:01
Date: Fri, 02 Nov 2001 07:01
122 lines
3708 bytes
3708 bytes
In article <20011101212918.T15113-100000@shell5.ba.best.com>,
Daniel Myers <dhm@best.com> wrote:
>--The new server has web statistics running a different version of Analog,
>which is accessible thru the Control Panel. However, this does not yet
>contain the nice referer and user-agent (snip). This additional
>information in the logs will be made available in the next week or two by
>request, and within a month we should have the information accessible thru
>the Control Panel's "view statistics" interface.
Until the HTTP_REFERER and HTTP_USER_AGENT fields show up, I've been
getting by with a modification to cgi-bin/count-ssi.cgi to log the
info for counted pages.
-Joe
#!/usr/bin/perl
use strict;
use Getopt::Std;
sub header {"Content-type: text/html\n\n"}; # Replace 'use CGI qw/:standard/;'
my $logfile="/usr/home/inwap/www/logs/referer_log";
use integer;
print header;
$|=1;
my %opt;
my $val = '';
my $orig_val = '';
my $path;
my @t;
my $last;
getopts('f:pi',\%opt);
$path = $ENV{'COUNTER_INFO'};
@t = split(/\//,$path);
pop(@t);
$path = join('/',@t);
chdir($path);
open(COUNT,$opt{'f'}) || die "Cannot open file: ".$opt{'f'};
while(<COUNT>) {
chomp;
next if($val ne '');
$val = $_;
$val =~ s/\D//g;
}
close(COUNT);
if($val eq '') {
$val = 0;
}
$orig_val = $val;
my $last3digits;
my $str = '';
my $started = 0;
if(!$opt{'p'}) {
while ($val >= 1000) {
$last3digits = $val % 1000;
$val = $val / 1000;
if ($started) {
$str = "," . sprintf("%03d", $last3digits) . $str;
} else {
$str = "," . sprintf("%03d", $last3digits);
$started = 1;
}
}
$str = $val . $str;
print $str;
$last = $orig_val % 10;
if ((($orig_val / 10) % 10) == 1) {
# we're in the teens, so fake the "th"
$last = 4;
}
if ($last == 1) {
print "st";
} elsif ($last == 2) {
print "nd";
} elsif ($last == 3) {
print "rd";
} else {
print "th";
}
}
if(!$opt{'i'}) {
$orig_val = $orig_val + 1;
open(COUNT,'>'.$opt{'f'}) || die "Cannot open file: ".$opt{'f'};
print COUNT $orig_val."\n";
close(COUNT);
}
# Log REFERER for any document using /cgi-bin/count-ssi.cgi for counter.
# Added by Joe.Smith@inwap.com 29-Oct-2001
my $ref = $ENV{HTTP_REFERER} || "-";
my $ua = $ENV{HTTP_USER_AGENT} || "-";
my $doc = $ENV{DOCUMENT_URI} || $ENV{REQUEST_URI} || $ENV{COUNTER_INFO};
exit 0 if ($ref eq "-") && ($ua = "-");
open(OUT,">>$logfile") || exit 1;
print OUT qq|$doc "$ref" "$ua"\n|;
close OUT;
exit(0);
--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.
Technical Details
Message-ID:
<9rtgbo$mmg$1@nntp1.ba.best.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news-peer-west.sprintlink.net!news.sprintlink.net!enews.sgi.com!news2.best.com!nntp1.ba.best.com!inwapReferences:
<20011030194803.O20312-100000@shell5.ba.best.com> <9rt6go$mbv$1@nntp1.ba.best.com> <20011101212918.T15113-100000@shell5.ba.best.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f9f6d,ef30c860af3a750a X-Google-Attributes: gidf9f6d,public X-Google-Thread: fdc27,1a2fbd8d0330ff21,start X-Google-Attributes: gidfdc27,public X-Google-ArrivalTime: 2001-11-01 23:01:52 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news-peer-west.sprintlink.net!news.sprintlink.net!enews.sgi.com!news2.best.com!nntp1.ba.best.com!inwap From: inwap@best.com (Joe Smith) Newsgroups: best.general,best.migration Subject: Post migration log formats Date: Fri, 2 Nov 2001 07:01:12 +0000 (UTC) Organization: Chez Inwap Lines: 122 Distribution: best Message-ID: <9rtgbo$mmg$1@nntp1.ba.best.com> References: <20011030194803.O20312-100000@shell5.ba.best.com> <9rt6go$mbv$1@nntp1.ba.best.com> <20011101212918.T15113-100000@shell5.ba.best.com> NNTP-Posting-Host: shell3.ba.best.com X-Trace: nntp1.ba.best.com 1004684472 23248 206.184.139.134 (2 Nov 2001 07:01:12 GMT) X-Complaints-To: abuse@best.com NNTP-Posting-Date: Fri, 2 Nov 2001 07:01:12 +0000 (UTC)