[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cobalt-users] run Webalizer after logfile split but before rotation



I've compiled Webalizer 2.01 to run on my Raq4 and stats ARE being generated
nightly for each site.  I want to schedule Webalizer to run AFTER the
/var/log/httpd/access logfile is split but BEFORE it is rotated/compressed
to avoid any holes in my stats.  I currently have webalizer.pl scheduled to
run at 4:30 AM which is calling webalizer twice, once on each site's web.log
then on each site's web.log.*.gz.  This is inefficient but works for the
time being (there's only a few low traffic sites on the machine).

Should webalizer.pl be called from /etc/logrotate.d/apache?  If so, where?
Any other suggestions?

In addition, I am unable to logon to www.domain/stats on FrontPage enabled
webs (even as admin).  Publishing with FrontPage is not an issue because I
have already changed the webalizer.pl script to chown the logfiles as nobody
as suggested in the archives.

Here's the webalizer.pl script I'm using (this should look familiar )

------------------

#!/usr/bin/perl

# Where sites on a RaQ4 live
$prefix = "/home/sites";
# Status messages
my $messages;

chdir "$prefix" or die "Can't cd to $prefix??: $!\n";
opendir THEROOT, $prefix or die "Couldn't open $prefix?: $!\n";
@allsites = grep !/^\.\.?$/,  readdir THEROOT;

foreach $asite (@allsites)
{
  if (-l "$asite")
  {
    $webpath = "$prefix/$asite/web";
    $thepath = "$prefix/$asite/web/stats";

    # Get the group id of the directory
    my $gid = (stat $webpath)[5];
    my $name = (getgrgid $gid)[0];

    # Create a directory /web/stats if it isn't there yet
    if (!-d $thepath)
    {
       mkdir $thepath, 775;
       chown 0, $gid, $thepath;
       chmod 0755, $thepath;
    }

    # Create a .htaccess if it isn't there yet
    if (!-e '$thepath/.htaccess')
    {
       my $string = "#Access file\norder allow,deny\nallow from all\nrequire
group $name\nAuthname WebStats\nAuthtype Basic";
       open HTACCESS, qq(>$thepath/.htaccess);
       print HTACCESS $string;
       close HTACCESS;
       chmod 0744, qq($thepath/.htaccess);
    }

    # Now just run webalizer
    $messages .=
       `webalizer -p -n $asite -s $asite -r $asite -Q -T -o $thepath
$prefix/$asite/logs/web.log.*.gz`;
       `webalizer -p -n $asite -s $asite -r $asite -Q -T -o $thepath
$prefix/$asite/logs/web.log`;
    # Now change ownership of stats files for siteadmin
    $messages .= `chown -R nobody:$name $thepath`;
  }
}

# Debugging printer, uncomment to use.
# These messages would be mailed to the box admin if you printed them
# and there actually were any.
# print $messages;
exit 0;

-----------

Thanks in advance for your suggestions.

James Lenhart