rebuilding data
What I'm going to put here is the problem, and the possible fix, and what you can do to recover stats. I assume you have access to RDP or the console of the server and you have administrator rights.
First, the problem:
Each domain with awstats configured needs a config file., since 8.3 I'm not sure which one is being used, there are 2, and both seem to be used in some cases, or at least rewritten (see later).
So, both config files:
- C:\Program Files\SWsoft\Plesk\Additional\AWStats\wwwroot\cgi-bin\awstats.domain.tld.conf
- G:\inetpub\vhosts\domain.tld\statistics\webstat\AWStats\cgi-bin\awstats.domain.tld.conf
('G:\inetpub' is my chosen location for the virtual hosts webroot.)
If you open both config files for awstat, you will find a line that says the following:
Code:
LogFormat="date time s-sitename s-computername s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs-version cs(User-Agent) cs(Cookie) cs(Referer) cs-host sc-status sc-substatus sc-win32-status sc-bytes cs-bytes time-taken"
This line is incorrect, and should be:
Code:
LogFormat="%time2 %other %cluster %other %method %url %query %other %logname %host %other %ua %other %referer %virtualname %code %other %other %bytesd %other %other"
You could go and change everything in all your config files, but let me just stop you right here. I did this yesterday, and found out that this morning all configfiles in G:\inetpub\vhosts\domain.tld\statistics\webstat\AWStats\cgi-bin have been overwritten, with the wrong LogFormat string off course. Only some of the configfiles in C:\Program Files\SWsoft\Plesk\Additional\AWStats\wwwroot\cgi-bin have been overwritten, also with the wrong LogFormat string.
I have not tested the new statistics.exe program yet, but I can maybe offer a solution for rebuilding missing data for people with missing stats.
First off all, you need as much of your old logfiles as possible, so hopefully you have a log rotation setup with enough logfiles to keep (since yesterday, 90 days with us, unchangeable by clients), otherwise, fall back to backups (I had to do this yesterday) etc...
Now be carefull and read this part carefully to avoid data loss! TAKE A BACKUP NOW of the directory G:\inetpub\vhosts\domain.tld
If your statistics are partial for a specific month, you will need to delete (move) the statistics for that and all months that follow the broken month. to rebuild them, you will need to have the logfiles for the domain in question for the ENTIRE broken month untill the current day.
In my case, the problems started on Feb 27 2008, so i first checked to see if I had all logfiles going back to Feb 1 2008 (with a restore from backups, I managed to have them for the entire month February).
What if you do not have all logfiles for the entire month? Bad luck, skip that month and check the next one.
Put all the logfiles in a place that is easy accessible, and where you have an overview of all the logfiles to process, for example in C:\restoredlogs\domain.tld\
Unzip the ones that are compressed.
Where do you look for logfiles:
Code:
G:\inetpub\vhosts\domain.tld\statistics\logs\W3SVC<xxxxx>\ex<YYMMDD>.log
They may be compressed in zip format, depends on your log rotation settings in Plesk, a .zip extension is added to the filename.
<xxxxx> represents a unique number, or identiefier, from IIS. Every website has a unique number to identify itself.
<YYMMDD> is the date where YY is the year, MM is the month and DD is the day, all with leading 0.
Go to G:\inetpub\vhosts\domain.tld\statistics\webstat
You will see a bunch of files in the format awstats<MMYYYY>.domain.tld.txt
<MMYYYY> is the month and year of data, MM being the month, YYYY being the year
Now look for the file for the month in which your stats got corrupted (Feb 2008 in my case). Move, delete, rename it (your choice, you are not going to need it anymore if everything goes right).
Do the same for all stat files following that month (in my case only Mar 2008).
DO THIS ONLY FOR THE MONTHS WHERE YOU HAVE ALL LOGFILES FOR (if my problem would have started in January, I would have to skip January, and check February, as I do not have all logfiles for January anymore)
Edit the file G:\inetpub\vhosts\domain.tld\statistics\webstat\AWStats\cgi-bin\awstats.domain.tld.conf and correct the faulty LogFormat line (see above).
Now open a command prompt and do the following:
- change to the directory G:\inetpub\vhosts\domain.tld\statistics\webstat\AWStats\cgi-bin
- execute the command:
Code:
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex<YYMMDD>.log"
Replace <YYMMDD> with the date of the logfile.
You can also put this in a batch file in the G:\inetpub\vhosts\domain.tld\statistics\webstat\AWStats\cgi-bin folder if you have a lot of files to process. An example of my batch file:
Code:
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex080201.log"
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex080202.log"
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex080203.log"
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex080204.log"
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex080205.log"
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex080206.log"
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex080207.log"
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex080208.log"
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex080209.log"
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex080200.log"
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex080210.log"
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex080211.log"
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex080212.log"
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex080213.log"
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex080214.log"
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex080215.log"
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex080216.log"
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex080217.log"
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex080218.log"
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex080219.log"
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex080220.log"
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex080221.log"
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex080222.log"
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex080223.log"
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex080224.log"
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex080225.log"
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex080226.log"
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex080227.log"
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex080228.log"
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex080229.log"
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex080301.log"
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex080302.log"
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex080303.log"
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex080304.log"
perl awstats.pl -update -config=domain.tld -logfile="C:\restoredlogs\domain.tld\ex080305.log"
Run this batchfile and all your statistics should be correct.
check this by going to the url
http://www.domain.tld/plesk-stat/webstat/AWStats/cgi-bin/awstats.pl?config=domain.tld
you can check this url while your batch file is running, you should see the data add whenever you refresh the page.
A special note: In my case, everything gets logged by IIS, but it may be different for your case. Check the faulty line against mine, if there are differences, you will need to remove the missing tags in the correct LogFormat line.