A few days ago I was asked to configure AWStats to count downloads of
.exe files on an website. I know that it’s blindingly obvious that AWStats isn’t the right tool for this job, but sometimes you have to pick battles with your clients. To save both my time and sanity I did what I was asked to do.
Interestingly, adding file download tracking functionality to AWStats proved to be very easy. In my case, the website was hosted on a cPanel server where AWStats was already installed, so I won’t cover the whole installation procedure.
So, the first thing I did was to enable AWStats configuration include file. On cPanel server, you can activate this feature in WHM > Statistics Software Configuration – simply check “Allow AWStats configuration Include file”. By enabling this feature, users will be able to put custom configuration in /home/username/tmp/awstats/awstats.conf.include file.
To track downloads of files with
.exe extension I’ve added the following configuration to
ExtraSectionName1=".exe downloads" ExtraSectionCodeFilter1="200 304" ExtraSectionCondition1="URL,(.*(\.exe))" ExtraSectionFirstColumnTitle1="Download" ExtraSectionFirstColumnValues1="URL,(.*)" ExtraSectionFirstColumnFormat1="<a href='http://your-domain.tld/%s' target=new title='Click to download file'>%s</a>" ExtraSectionStatTypes1=HBL ExtraSectionAddAverageRow1=0 ExtraSectionAddSumRow1=1
The configuration is pretty self-explanatory – it defines category title that is shown in AWStats side menu, HTTP codes that are filtered, regex for catching request for
.exe files etc. With custom configuration in place, after the next statistics calculation run you will have a new section in AWStats.