Applicable to:
- Plesk Onyx for Windows
Question
How to recalculate statistics using old IIS log files starting from a particular date?
Answer
When the
statistics.exe
utility is run, either manually or during daily maintenance, it performs the following actions to calculate statistics for each domain:
-
Parse IIS log files for the domain and only select non-processed records.
-
Merge the selected records with the records from the default website log file.
-
Process the resulting log file with the native statistics backend (AWStats or Webalizer).
It is required to review script for Plesk Obsidian! The recalculation can be performed using PowerShell scripts for Plesk 17. Download the script to the server, unzip it and right-click the script file, select "Run with PowerShell".
Follow the steps below to recalculate statistics from a given date to the current date:
- Ensure Log Rotation is enabled and configured
- Go to IIS > Sites > example.com > Logging and enable all fields for W3C logging:
-
Verify that domain log files are not compressed and contain data:
Use this command to find the log's location:
C:\> "%plesk_dir%"\admin\bin64\websrvmng.exe --get-vhost-log-dir --vhost-name=example.com
C:\Inetpub\vhosts\example.com\logs\W3SVC11Unzip and place all the log files that should be processed by statistics into the folder above. Make sure they have the
.log
extension. It also may be a good idea to merge them all into a single.log
file. -
Change the value of
LastHttpStatisticsRun
for the domain in the registry:Retrieve the domain ID from Plesk database:
C:\> "%plesk_bin%"\dbclient.exe --direct-sql --sql="SELECT id, name FROM domains WHERE name='example.com'"
id name
40 example.comChange the value of this registry key to the date from which statistics will be recalculated:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\PLESK\PSA Config\Config\Statistics\DomainIds\40\LastHttpStatisticsRun
(where "40" is the domain ID obtained above from the
psa
database)If there is no
LastHttpStatisticsRun
in the registry, all available log files will be recalculated. -
If it is needed to recalculate statistics for a part of the current month, edit this file (in this example, the current month is November 2019):
C:\inetpub\vhosts\example.com\.plesk\statistics\example.com\webstat\awstats112019.example.com.txt
Remove the lines starting with the following keywords from the file above:
LastLine
LastTime
LastUpdate
-
If it is needed to recalculate statistics for one or more months, delete the AWStats databases from the very first month for which the statistics need to be recalculated. For example, to recalculate statistics for September 2019 (and it is now November 2019), delete the following files:
C:\inetpub\vhosts\example.com\.plesk\statistics\example.com\webstat\awstats092019.example.com.txt
C:\inetpub\vhosts\example.com\.plesk\statistics\example.com\webstat\awstats102019.example.com.txt
C:\inetpub\vhosts\example.com\.plesk\statistics\example.com\webstat\awstats112019.example.com.txtIf this step is forgotten, AWStats will ignore all log files as if they only contained old records.
-
Remove the DNS cache file:
C:\inetpub\vhosts\example.com\.plesk\statistics\example.com\webstat\dnscachelastupdate.example.com.txt
-
Calculate the statistics:
C:\> "%plesk_bin%"\statistics.exe --calculate-one --domain-name=example.com
Alternatively, launch the Plesk Daily Maintenance scheduled task using the Windows Schedule tasks snap-in.
-
If the last step did not result in the statistics update, execute the below command:
C:\> "%plesk_bin%"\statistics.exe --generate-domain-webstat --domain-name=example.com
-
For cases when
u_extend**.log
contains full statistics information, butweb***.log
does not:- Check particular date when statistics stopped being updated in
web***.log
file.- Locate the same date in
u_extend**.log
file and analyze it's content. - If there are some not well-formatted lines, edit them so that they look like the others, for example:
CONFIG_TEXT: #Software: Microsoft Internet Information Services 8.0
#Version: 1.0
#Date: 2015-05-22 00:28:14The first line is wrongly configured. It should be:
CONFIG_TEXT: #Software: Microsoft Internet Information Services 8.0
#Version: 1.0
#Date: 2015-05-22 00:28:14
Recalculate for all domains (needs reuse to move o public)
1. In the Windows command line run the following command which will create the list of all domains on the server and put it in the file on the desktop (check if file created okay):
plesk db -Ne "select name from domains" > C:\Users\Administrator\Desktop\domains_list.txt
2. Run the PowerShell script:
Get-Content C:\Users\Administrator\Desktop\domains_list.txt | ForEach-Object {
C:\Users\Administrator\Desktop\wsrecalc_17.ps1 $_ 01.01.21
}
Note: change the date for the required one (dd.MM.yy).
Comments
0 comments
Please sign in to leave a comment.