anyone else using webalizer?



Hello everyone I wrote a little script in perl to dig the stats out of
the usage.html files. Looks like webalizer preservers old files, so
log rotation can be achieved by fliping the log on the first of the
months. Here is a script that uses the sorttable.js script from
kryogenix.org. It must be in the same folder as the usage.html files
and therefore exec must be enable.

#!/usr/bin/perl -w
use HTML::TokeParser;

print <<EOF;
Content-Type: text/html

<HTML>
<HEAD>
<script src="sorttable.js"></script>
<TITLE>Usage Statistics</TITLE>
</HEAD>
<BODY BGCOLOR="#E8E8E8" TEXT="#000000" LINK="#0000FF"
VLINK="#FF0000"><center>
<TABLE class="sortable">
<thead>
<tr>
<th>Date</th>
<th>T Hits</th>
<th>T Files</th>
<th>T Pages</th>
<th>T Visits</th>
<th>T KBytes</th>

<th>U Sites</th>
<th>U URLs</th>
<th>U Referrers</th>
<th>U Usernames</th>
<th>U User Agents</th>
</tr>
</thead>
<tbody>
EOF

$startofline = "<TR><TD>";
$separator = "<\/TD><TD>";
$endofline = "<\/TD><\/TR>\n";

opendir(DIR, ".");
my @files = sort(grep(/^usage_/,readdir(DIR)));
closedir(DIR);

sort(@files);

foreach $file (@files) {
$name = $file;
$name =~ s/\.html//g;
$name =~ s/usage\_//g;

print "$startofline<A HREF=\"$file\">$name<\/A>$separator";

$p = HTML::TokeParser->new(shift||"$file");

$i = 0;
while (my $token = $p->get_tag("b")) {
$i++;
if ($i > 10){ last;}

my $text = $p->get_trimmed_text("/b");


if (($i > 0) and ($i < 10)){ print "$text$separator";}

if ($i eq 10){ print "$text$endofline";}

} #end of while token

}


print "</tbody><\/TABLE>";
print "<\/CENTER><\/BODY><\/HTML>";
.



Relevant Pages

  • Re: Log rotation
    ... I have a script that when executed will write debug and error messages ... I want to create log rotation such a way that if the file size of ... Jerry Stuckle ... JDS Computer Training Corp. ...
    (comp.lang.php)
  • shell scripting - automating rotation of files in different directories
    ... have looked at a couple of the ports for log rotation and such, ... Looking for a way to simply touch or delete log files and have the script ... the next time the script runs it will rotate all them... ...
    (freebsd-questions)
  • Re: Log rotation
    ... I want to create log rotation such a way that if the file size of ... but it's what I used before i started logging to a db. ... This was for multiple script calls logging to the same file, $u_id made it easy to group the entries. ...
    (comp.lang.php)
  • Re: Log rotation
    ... I have a script that when executed will write debug and error messages ... Jerry Stuckle ... JDS Computer Training Corp. ... Have you searched for log rotation scripts? ...
    (comp.lang.php)
  • Re: Wanted - program to log the noise margin of a router
    ... The script used wget to ... >>>the router stats page locally, then parsed the page it had downloaded to ... >> You make me feel I have the brain of a cat! ... > Linux scripting could be written on a matchbox. ...
    (uk.telecom.broadband)