Home » Apache

Modifying awstats to show total hits for matching files

3 November 2011 One Comment

Here’s a quick modification to awstats that allows you to add a totals field for the “Viewed – Full List” option. There isn’t a total hits field for matching files in awstats, so I added one to make it more useful. This makes it a lot quicker to total up hits for a specific folder, file type, or specific file in awstats.

The information provided below is for informational purposes only.

1) Locate your awstats.pl file.
If you are using the awstats Debian/Ubuntu package, awstats is located in /usr/lib/cgi-bin/awstats.pl.

2) Backup the awstats.pl file.
cp awstats.pl awstats.pl.bak

3) Open up the awstats.pl file in your favorite text editor. Find line 8468 (approximately, depending on your version of awstats).

There should be the following code:
&tab_end();
&html_end(1);
}
if ($HTMLOutput{'unknownos'}) {

4) Above the &tab_end(); add the following lines:
# Total up the matching pages
print "<tr><td style=\"text-align: left\"><strong>Total</strong></td><td><strong>$total_p</strong></td></tr>\n";

The end result should look like:
# Total up the matching pages
print "<tr><td style=\"text-align: left\"><strong>Total</strong></td><td><strong>$total_p</strong></td></tr>\n";
&tab_end();
&html_end(1);
}
if ($HTMLOutput{'unknownos'}) {

5) Save the awstats.pl file. Any future updates to Awstats package will overwrite these changes, but the fix should only take a minute to add it back in. If it doesn’t work, copy the awstats.pl.bak file as awstats.pl.

The modification will add the totals row for the following awstats reports:

One Comment »

  • Al said:

    Wrote up a quick tutorial on modifying awstats to show total hits for matching files. http://t.co/Xcr5r59u

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.

*