How to recalculate statistics starting from a particular date on a Windows server?


2016-11-16 13:04:46 UTC


2017-08-16 16:20:40 UTC


Was this article helpful?

Have more questions?

Submit a request

How to recalculate statistics starting from a particular date on a Windows server?

Applicable to:

  • Plesk for Windows


How to recalculate statistics using old IIS log files starting from a particular date?


Before following the steps below, it is recommended to gain an understanding of the overall process of statistics calculation. When the statistics.exe utility is run, either manually or during daily maintenance, it performs the following actions to calculate statistics for each domain on the server:

  1. Parse IIS log files for the domain and only select non-processed records.

  2. Merge the selected records with the records from the default website log file.

  3. Process the resulting log file with the native statistics backend (AWStats or Webalizer).

The recalculation can be performed using PowerShell scripts for Plesk 17 and Plesk 12.5 . Download one of the scripts to the server, unzip it and right-click the script file, select "Run with PowerShell".

Alternatively, follow the steps below to recalculate statistics from a given date to the current date.

  1. Ensure Log Rotation is enabled and configured, and ensure that all fields for W3C logging are checked in IIS > Sites > > Logging .
  2. Verify the domain log files are not compressed and contain data:

    Use this command to find the log's location:

    "%plesk_bin%"\websrvmng.exe --get-vhost-log-dir

    Unzip 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.

  3. Change the value of LastHttpStatisticsRun for the domain in the registry:

    Retrieve the domain ID from the psa database using this command:

    "%plesk_bin%"\dbclient.exe --direct-sql --sql="SELECT id, name FROM domains WHERE name=''"
    id name

    Change 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.

  4. If it is needed to recalculate statistics for a portion of the current month, edit this file (in this example, the current month is November 2012):


    Remove the lines starting with the following keywords from the file above:


    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 2012 (and it is now November 2012), delete the following files:


    If this step is forgotten, AWStats will ignore all log files as if they only contained old records.

  5. Remove the DNS cache file:

  6. Calculate statistics using this command:

    "%plesk_bin%"\statistics.exe --calculate-one

    Alternatively, launch the Plesk Daily Maintenance scheduled task using the Windows Schedule tasks snap-in.

  7. If the last step did not result in the statistics update, execute the below command:

    "%plesk_bin%"\statistics.exe --generate-domain-webstat
  8. For cases when u_extend**.log contains full statistics information, but web***.log does not:

  9. Check particular date when statistics stopped being updated in web***.log file.

  10. Locate the same date in u_extend**.log file and analyze it's content.
  11. If there are some not well formatted lines, edit them so that they look like the others, for example:

    #Software: Microsoft Internet Information Services 8.0
    #Version: 1.0
    #Date: 2015-05-22 00:28:14

    The first line is wrongly configured. It should be:

    #Software: Microsoft Internet Information Services 8.0
    #Version: 1.0
    #Date: 2015-05-22 00:28:14


Have more questions? Submit a request
Please sign in to leave a comment.