Hey there,
I've written a script that calls AWStats to generate static statistics pages
for a given site on a certain month, and place those files into a directory
for that month... It has been working fine up until 31st of July, but when
the 1st of August came around, it mysteriously stopped doing anything...
here's is the code, can anyone here see anything screwy with it?
=== PHP Code begin ===
#!/usr/bin/php
<?
//
// AWStats history script.
//
// This script is designed to execute awstats_buildst aticpages.pl
// and output to a different directory each month
//
//
// Directory containing log files to be analysed
//
$logdir = '/path/to/logs';
//
// the config file to use: awstats.$config file.conf
//
$configfile = 'someuser';
//
// !-END USER CONFIG-!
// Do not modify below, unless you know exactly what you're doing
//
$month = date('m');
$outputdir = $logdir . '/' . $month;
switch($month) {
case 01:
if(!(is_dir($ou tputdir))) {
mkdir($outputdi r, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildst aticpages.pl -config=$configf ile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
case 02:
if(!(is_dir($ou tputdir))) {
mkdir($outputdi r, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildst aticpages.pl -config=$configf ile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
case 03:
if(!(is_dir($ou tputdir))) {
mkdir($outputdi r, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildst aticpages.pl -config=$configf ile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
case 04:
if(!(is_dir($ou tputdir))) {
mkdir($outputdi r, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildst aticpages.pl -config=$configf ile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
case 05:
if(!(is_dir($ou tputdir))) {
mkdir($outputdi r, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildst aticpages.pl -config=$configf ile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
case 06:
if(!(is_dir($ou tputdir))) {
mkdir($outputdi r, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildst aticpages.pl -config=$configf ile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
case 07:
if(!(is_dir($ou tputdir))) {
mkdir($outputdi r, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildst aticpages.pl -config=$configf ile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
case 08:
if(!(is_dir($ou tputdir))) {
mkdir($outputdi r, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildst aticpages.pl -config=$configf ile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
case 09:
if(!(is_dir($ou tputdir))) {
mkdir($outputdi r, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildst aticpages.pl -config=$configf ile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
case 10:
if(!(is_dir($ou tputdir))) {
mkdir($outputdi r, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildst aticpages.pl -config=$configf ile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
case 11:
if(!(is_dir($ou tputdir))) {
mkdir($outputdi r, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildst aticpages.pl -config=$configf ile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
case 12:
if(!(is_dir($ou tputdir))) {
mkdir($outputdi r, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildst aticpages.pl -config=$configf ile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
default:
$result = "Could not generate stats! " . date('M j g:ia y') . "\n";
break;
}
$resultfile = $logdir . '/AWSResult.txt';
$fh = fopen($resultfi le, 'w');
fwrite($fh, $result);
fclose($fh);
=== PHP Code end ===
So, I have sites that have 06, 07 etc directories where I want them, and the
AWSResult.txt file used to contain the output from
awstats_buildst aticpages.pl, but now I just get the default "Could not
generate stats!" error. The $configfile, $month and $outputdir vars are all
set exactly how I expect them to be, so I'm not sure why it isn't picking up
the fact that the $month var is '08' and skips to the 'default' instead of
'case 08' ... HELP !!! Like I said it was working without a hitch up until
the 1st of August.
Thanks in advance...
Regards,
Aidan
I've written a script that calls AWStats to generate static statistics pages
for a given site on a certain month, and place those files into a directory
for that month... It has been working fine up until 31st of July, but when
the 1st of August came around, it mysteriously stopped doing anything...
here's is the code, can anyone here see anything screwy with it?
=== PHP Code begin ===
#!/usr/bin/php
<?
//
// AWStats history script.
//
// This script is designed to execute awstats_buildst aticpages.pl
// and output to a different directory each month
//
//
// Directory containing log files to be analysed
//
$logdir = '/path/to/logs';
//
// the config file to use: awstats.$config file.conf
//
$configfile = 'someuser';
//
// !-END USER CONFIG-!
// Do not modify below, unless you know exactly what you're doing
//
$month = date('m');
$outputdir = $logdir . '/' . $month;
switch($month) {
case 01:
if(!(is_dir($ou tputdir))) {
mkdir($outputdi r, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildst aticpages.pl -config=$configf ile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
case 02:
if(!(is_dir($ou tputdir))) {
mkdir($outputdi r, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildst aticpages.pl -config=$configf ile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
case 03:
if(!(is_dir($ou tputdir))) {
mkdir($outputdi r, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildst aticpages.pl -config=$configf ile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
case 04:
if(!(is_dir($ou tputdir))) {
mkdir($outputdi r, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildst aticpages.pl -config=$configf ile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
case 05:
if(!(is_dir($ou tputdir))) {
mkdir($outputdi r, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildst aticpages.pl -config=$configf ile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
case 06:
if(!(is_dir($ou tputdir))) {
mkdir($outputdi r, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildst aticpages.pl -config=$configf ile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
case 07:
if(!(is_dir($ou tputdir))) {
mkdir($outputdi r, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildst aticpages.pl -config=$configf ile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
case 08:
if(!(is_dir($ou tputdir))) {
mkdir($outputdi r, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildst aticpages.pl -config=$configf ile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
case 09:
if(!(is_dir($ou tputdir))) {
mkdir($outputdi r, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildst aticpages.pl -config=$configf ile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
case 10:
if(!(is_dir($ou tputdir))) {
mkdir($outputdi r, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildst aticpages.pl -config=$configf ile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
case 11:
if(!(is_dir($ou tputdir))) {
mkdir($outputdi r, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildst aticpages.pl -config=$configf ile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
case 12:
if(!(is_dir($ou tputdir))) {
mkdir($outputdi r, 0755);
}
$result = `perl
/usr/local/awstats/tools/awstats_buildst aticpages.pl -config=$configf ile -mo
nth=$month -update -dir=$outputdir -diricons=http://domain.com/awstatsicons`
;
break;
default:
$result = "Could not generate stats! " . date('M j g:ia y') . "\n";
break;
}
$resultfile = $logdir . '/AWSResult.txt';
$fh = fopen($resultfi le, 'w');
fwrite($fh, $result);
fclose($fh);
=== PHP Code end ===
So, I have sites that have 06, 07 etc directories where I want them, and the
AWSResult.txt file used to contain the output from
awstats_buildst aticpages.pl, but now I just get the default "Could not
generate stats!" error. The $configfile, $month and $outputdir vars are all
set exactly how I expect them to be, so I'm not sure why it isn't picking up
the fact that the $month var is '08' and skips to the 'default' instead of
'case 08' ... HELP !!! Like I said it was working without a hitch up until
the 1st of August.
Thanks in advance...
Regards,
Aidan
Comment