Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 3 > Installation/Configuration

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 20th July 2011, 12:51
erosbk erosbk is offline
Senior Member
 
Join Date: Mar 2011
Posts: 337
Thanks: 49
Thanked 36 Times in 30 Posts
Default AWStats does not calculate last day

AWStats statistics program does not calculate last day of month. As I could see, every day 1 of all months, in stats I can only see the current month, instead of previous month with traffic of the last day.

Is this normal for AWstats in ispconfig? or is just a bug in my installation?
Reply With Quote
Sponsored Links
  #2  
Old 20th July 2011, 14:55
erosbk erosbk is offline
Senior Member
 
Join Date: Mar 2011
Posts: 337
Thanks: 49
Thanked 36 Times in 30 Posts
Default

As I could see, reinstalling everything in a VM, ISPConfig is not calculating last day of previous month, directly calculating the new month showing all values in zero...

I will follow in this post what I wrote here:
http://www.howtoforge.com/forums/showthread.php?t=53282

I added this code to cron_daily, in a VM using log files and previous stats from a production server but... when I calculate last day for a previous month, all previous data is removed...

I will test this in 10 days in my production server to see if it works as it should... but I think that I will have the same results... so, please help, I think that this could be great for clients to see preivous month statistics and compare between months.

--- with this script right now, every first day of month, stats will be calculated twice, one for current month, one for previous month (to complete last day). This can be modified to always calculate one time only, and day 2 copy files to "previous month folder" BEFORE running stats calculation... ---

Code:
#######################################################################################################
// Create awstats statistics
#######################################################################################################

$sql = "SELECT domain_id, domain, document_root FROM web_domain WHERE stats_type = 'awstats' AND server_id = ".$conf['server_id'];
$records = $app->db->queryAllRecords($sql);

$web_config = $app->getconf->get_server_config($conf['server_id'], 'web');

foreach($records as $rec) {
	//$yesterday = date('Ymd',time() - 86400);
	$yesterday = date('Ymd',strtotime("-1 day", time()));
	$logfile = escapeshellcmd($rec['document_root'].'/log/'.$yesterday.'-access.log');
	if(!@is_file($logfile)) {
		$logfile = escapeshellcmd($rec['document_root'].'/log/'.$yesterday.'-access.log.gz');
		if(!@is_file($logfile)) {
			continue;
		}
	}

	$domain = escapeshellcmd($rec['domain']);
	$statsdir = escapeshellcmd($rec['document_root'].'/web/stats');
// BOC 1: Copy previous month statistics to dir /[year][month]/*
        if (date("d") == 1)
        {
                $statsprev = '/'.date("Y").(date("m")-1);
                if (date("m") == 1)
                {
                        $statsprev = '/'.(date("Y")-1).'12';
                }
        }
	$statsdirold = $statsdir.$statsprev."/";
	mkdir($statsdirold);
	$files = scandir($statsdir);
	foreach ($files as $file)
	{
              if (substr($file,0,1) != "." && substr($file,0,1) != "2" ) copy("$statsdir"."/"."$file", "$statsdirold"."$file");
	}
// EOC 1:


	$awstats_pl = $web_config['awstats_pl'];
	$awstats_buildstaticpages_pl = $web_config['awstats_buildstaticpages_pl'];
	$awstats_conf_dir = $web_config['awstats_conf_dir'];
	$awstats_website_conf_file = $web_config['awstats_conf_dir'].'/awstats.'.$domain.'.conf';
	
	if(is_file($awstats_website_conf_file)) unlink($awstats_website_conf_file);
	
	if(!is_file($awstats_website_conf_file)) {
		$awstats_conf_file_content = 'Include "'.$awstats_conf_dir.'/awstats.conf"
LogFile="/var/log/ispconfig/httpd/'.$domain.'/yesterday-access.log"
SiteDomain="'.$domain.'"
HostAliases="www.'.$domain.' localhost 127.0.0.1"';
		file_put_contents($awstats_website_conf_file,$awstats_conf_file_content);
	}
	
	if(!@is_dir($statsdir)) mkdir($statsdir);
	if(is_link('/var/log/ispconfig/httpd/'.$domain.'/yesterday-access.log')) unlink('/var/log/ispconfig/httpd/'.$domain.'/yesterday-access.log');
	symlink($logfile,'/var/log/ispconfig/httpd/'.$domain.'/yesterday-access.log');
	
	// awstats_buildstaticpages.pl -update -config=mydomain.com -lang=en -dir=/var/www/domain.com/web/stats -awstatsprog=/path/to/awstats.pl
	$command = "$awstats_buildstaticpages_pl -update -config='$domain' -lang=en -dir='$statsdir' -awstatsprog='$awstats_pl'";
	
	if($awstats_pl != '' && $awstats_buildstaticpages_pl != '' && fileowner($awstats_pl) == 0 && fileowner($awstats_buildstaticpages_pl) == 0) {
		exec($command);
		rename($rec['document_root'].'/web/stats/awstats.'.$domain.'.html',$rec['document_root'].'/web/stats/index.html');
		$app->log('Created awstats statistics with command: '.$command,LOGLEVEL_DEBUG);

// BOC 2: Calculate last day for previous month. -month and -year must be variables, right now are fixed values for testing purpose
	        if (date("d") == 1)
	        {
		        $command = "$awstats_buildstaticpages_pl -month=06 -year=2011 -update -config='$domain' -lang=en -dir='$statsdirold' -awstatsprog='$awstats_pl'";
        	        exec($command);
                	rename($rec['document_root'].'/web/stats'.$statsprev.'/'.'awstats.'.$domain.'.html',$rec['document_root'].'/web/stats/'.$statsprev.'/'.'index.html');
	        }
// EOC 2:

// BOC 3: Add code here to create a index.html with dropdown list to select year/month to view, and point selection to directory. This can be done for ispconfig when AWStats are selected as web stats type, and create one time as static index.html, creating drop down reading directories dinamically...
// EOC 3:

	} else {
		$app->log("No awstats statistics created. Either $awstats_pl or $awstats_buildstaticpages_pl is not owned by root user.",LOGLEVEL_WARN);
	}
	
}

Last edited by erosbk; 20th July 2011 at 14:59.
Reply With Quote
  #3  
Old 19th January 2012, 18:34
critorix critorix is offline
Junior Member
 
Join Date: Jan 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Did you succeed in showing more than one month in awstats ?

I have the same problem.

Thanks in advance.
critorix
Reply With Quote
  #4  
Old 19th January 2012, 18:38
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 36,396
Thanks: 833
Thanked 5,492 Times in 4,323 Posts
Default

This has been fixed long ago.You should update ispconfig on your server to the recent version (3.0.4.2).
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #5  
Old 19th January 2012, 18:47
critorix critorix is offline
Junior Member
 
Join Date: Jan 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok, thank you.

I have the 3.0.3.3, is it possible to re-generate the previous months stats after the upgrade ?
Reply With Quote
  #6  
Old 19th January 2012, 19:09
erosbk erosbk is offline
Senior Member
 
Join Date: Mar 2011
Posts: 337
Thanks: 49
Thanked 36 Times in 30 Posts
Default

Quote:
Originally Posted by critorix View Post
Ok, thank you.

I have the 3.0.3.3, is it possible to re-generate the previous months stats after the upgrade ?
If you have a backup of previous stats, after upgrade it is possible. But if you don't have a backup of previous stats I don't know how much you can go back to previous logs to regenerate stats from them..
Reply With Quote
  #7  
Old 19th January 2012, 21:55
critorix critorix is offline
Junior Member
 
Join Date: Jan 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
 
Default

Thank you.

I upgraded to the latest version and will try to regenerate stats.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
HOWTO: Run AWStats from the Command Line linus3x Tips/Tricks/Mods 1 22nd October 2010 22:54
Need help setting up or accessing AWStats on 3.0.2 please jwlinux Installation/Configuration 2 17th April 2010 16:38
Awstats config problem Paladinemishakal HOWTO-Related Questions 1 13th February 2009 13:38
Ispconfig + awstats on debian etch Dennis Installation/Configuration 1 19th April 2008 22:57
Suse Ispconfig and AWstats shajazzi Installation/Configuration 4 15th May 2006 23:04


All times are GMT +2. The time now is 11:50.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.