33

I have many old log files (apache) and they span 3 different VPS servers I've had so there are different sets with the same name:

old vps 1 (jan. 2012 - mar. 2012) -> access.log.1.gz

old vps 2 (apr. 2012 - oct. 2012) -> access.log.1.gz

etc..

Is there an awstats command that will analyze ALL of the old log files and generate the reports with the correct dates? And do I need to gunzip the files or rename them before I can run the command?

Zachary Uram
  • 441
  • 1
  • 4
  • 4
  • Can you just concatenate them all into one file? Also awstats has it's own forum at http://sourceforge.net/p/awstats/discussion/43428 – Apprentice Queue Dec 12 '12 at 20:09

4 Answers4

75

You can use the logresolvemerge.pl tool (see FAQ-COM350). Either you change the LogFile Option in the .conf file, or (for a one-time run) use it as argument in an update.

LogFile="/path/to/logresolvemerge.pl access.log* |"

An example (on a debian based system) for a command line update:

/usr/lib/cgi-bin/awstats.pl -update -config="example.com" -LogFile="/usr/share/awstats/tools/logresolvemerge.pl /var/log/apache2/access.log* |"

Remark: It is possible, that you need to clean the existing statistic-data. See FAQ-COM500.

redimp
  • 1,061
  • 8
  • 12
  • 1
    For further information, old information may not be included in newer information is already parsed. In this case remove previous information (DirData directory) and process everything again. https://awstats.sourceforge.io/docs/awstats_faq.html#FAQ-COM500 – Tom Aug 21 '19 at 19:34
  • @Zachary Uram pls mark this answer (or another) as solution? – zypro Jan 13 '21 at 09:46
8

If you need a Windows version of this for either the command line or a site configuration file, you can use exactly the same syntax style:

LogFile="C:/WebRoot/MYSITE~1/traffic/aws/tools/logresolvemerge.pl C:/MYPROG~1/Apache24/logs/access/access_log.* |"

Note the use of DOS short names for folders with spaces. You can obtain DOS short names for a file or folder with dir /x from the command line (DOS prompt).

Anaksunaman
  • 236
  • 5
  • 13
  • How do you specify the configuration it is for? – PeterX Oct 30 '15 at 02:40
  • @PeterX If I am understanding you correctly, you need to make a copy or copies of awstats.model.conf from the awstats-7.x\wwwroot\cgi-bin directory in Windows and modify it (them) to your needs for each set of logs you wish to process. This is the first line in that file. It presupposes that you are already somehow separating your log files (generally or on a per-site basis, say, via your server) and need to "merge" them in order to be processed as a whole by awstats. The second operator thus assumes a pre-grouped set of files. Note that awstats.model.conf has a "SiteDomain" variable as well. – Anaksunaman Oct 30 '15 at 06:35
  • Ahh, I misunderstood, the config setting above is already in the relevant config file. Thanks. – PeterX Nov 12 '15 at 07:25
  • What `LogFormat` are you using? Apparently `logresolvemerge` [won't work](http://www.internetofficer.com/forum/awstats-iis-installation-and-configuration/issues-with-logresolvemerge-pl-results-and-logformat/) with the setting at `2` and you need to use a "long" format, however I haven't been able to get any samples to work. – PeterX Nov 12 '15 at 07:59
2

In Windows, I had to use the following entry: (added "PERL", path to my install folder, and inclue *.log before the pipe)

LogFile="PERL C:/AWSTATS/tools/logresolvemerge.pl C:/AWSTATS/wwwroot/cgi-bin/stats/logFiles/*.log |"

dhaworth
  • 57
  • 6
0

For an IIS installation on Windows you can run the following on Command Prompt:

perl "D:/Websites/My Website/Stats/cgi-bin/awstats.pl" -update -config="mywebsite.com" -LogFile="perl \"D:/Websites/My Website/Stats/tools/logresolvemerge.pl\" C:\inetpub\logs\LogFiles\W3SVC1\*.log |"

Based on:

  1. perl being on your PATH environment variable
  2. Your website being stored in D:/Websites/My Website
  3. The contents of AWStats' wwwroot folder being stored in a folder named Stats one level deeper
  4. AWStats' tools folder being stored within that folder (you might want to only do this temporarily so that they can't be accessed via a web browser)
  5. Your config file being named awstats.mywebsite.com.conf
Danny Beckett
  • 20,529
  • 24
  • 107
  • 134