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

Refers to:

  • Plesk for Windows

Created:

2016-11-16 13:04:46 UTC

Modified:

2017-01-25 19:58:32 UTC

0

Was this article helpful?


Have more questions?

Submit a request

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

Question

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

Answer

Before following the steps below, it is recommended to gain 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 steps below describe how to properly 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 > example.com > 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 --vhost-name=example.com
    C:\\Inetpub\\vhosts\\example.com\\logs\\W3SVC11

    Unzip and place all the log files you want to be processed by statistics into the above folder. 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='example.com'"
    id name
    40 example.com

    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):

    C:\\inetpub\\vhosts\\example.com\\.plesk\\statistics\\example.com\\webstat\\awstats112012.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 needs to be recalculated. For example, to recalculate statistics for September 2012 (and it is now November 2012), delete the following files:

    C:\\inetpub\\vhosts\\example.com\\.plesk\\statistics\\example.com\\webstat\\awstats092012.example.com.txt
    C:\\inetpub\\vhosts\\example.com\\.plesk\\statistics\\example.com\\webstat\\awstats102012.example.com.txt
    C:\\inetpub\\vhosts\\example.com\\.plesk\\statistics\\example.com\\webstat\\awstats112012.example.com.txt

    If you accidentally forget this step, AWStats will ignore all log files as if they only contained old records.

  5. Remove the DNS cache file:

    C:\\inetpub\\vhosts\\example.com\\.plesk\\statistics\\example.com\\webstat\\dnscachelastupdate.example.com.txt
  6. Calculate statistics using this command:

    "%plesk_bin%"\\statistics.exe --calculate-one --domain-name=example.com

    In Plesk 11.0 and earlier, use the following command:

    "%plesk_bin%"\\statistics.exe --process-domains=example.com --verbose

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

  7. If the last step did not cause your statistics to be updated, execute the below command:

    "%plesk_bin%"\\statistics.exe --generate-domain-webstat --domain-name=example.com

    In Plesk 11.0 and earlier, use the following command:

    "%plesk_dir%"\\admin\\bin\\web_statistics_executor.exe --calculate-domain --webspace-name=example.com --domain-name=example.com
  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 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

Additional Information

If the statistics are incorrect, try the instructions in the following article, which should help you avoid such issues in the future:

#3606 - [Info] Statistics are calculated incorrectly: "Bad allocation" error

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