HOWTO: Run AWStats from the Command Line

Discussion in 'Tips/Tricks/Mods' started by linus3x, Oct 22, 2010.

  1. linus3x

    linus3x New Member

    We recently needed to run a midday report of AWStats and I wanted to share what we learned. Because ISPConfig 3 runs one report at 12:30 AM, I decided to kick off a midday run of AWStats from the command line.

    These instructions are for Debian Lenny.


    Note: If you ever want to run ISPConfig's entire nightly cron job from the command line (which includes the AWStats reports), you can use:

    Code:
    /usr/local/ispconfig/server/cron_daily.sh
    The instructions that follow assume that you only want to update AWStats for a single website.


    First of all, I’m assuming you’ve got ISPConfig 3 installed correctly and that all of the AWStats paths are set to the defaults on the System > Server Config > Web tab. In addition, I’ll assume that when you set up your Website > Web Domain > Statistics tab, you entered in a password and you selected AWStats as your Webstatistics program.

    If so, then you can imitate what ISPConfig 3 does when it does its run. First go to this directory:

    Code:
    cd /etc/awstats/
    Run ls and look for a file with your domain name in it. It’ll be something like:

    Code:
    awstats.[B]yourdomain.com[/B].conf
    
    That’s your site’s config file. You’ll need to know whatever is between awstats and conf when you do the update. Here’s it just yourdomain.com but if the file were named something like:

    Code:
    awstats.[B]www.yourdomain.info[/B].conf
    You’d need:

    Code:
    www.yourdomain.info
    Make sense?

    Ok, next you’re going to need to know where to place the output files. If you’ve gone with the defaults, this is probably going to be something like this:

    Code:
    /var/www/clients/[B]client1[/B]/[B]web1[/B]/web/stats
    Where client1 and web1 are whatever is displayed on the Website > Web Domain > Options tab. (If you’ve made any adjustments to the System > Server Config > Web tab > Website path you’ll need to adjust your output path accordingly.)

    You’re ready to run the command, substituting in your information:

    Code:
    /usr/share/awstats/tools/awstats_buildstaticpages.pl -config=[B]yourdomain.com[/B] -update -awstatsprog=/usr/lib/cgi-bin/awstats.pl -dir=[B]/var/www/clients/client1/web1/web/stats[/B]
    So breaking it down:

    Code:
    -config=whatever was the “[B]xxx[/B]” in your awstats.[B]xxx[/B].conf file name
    -update run an update to pick up the latest stats
    -awstatsprog=path to awstats.pl on your system
    -dir=your output file directory
    Once you’re done, you can access your stats using something similar to the following:

    Code:
    http://www.[B]yourdomain.com[/B]/stats/awstats.[B]yourdomain.com[/B].html
    You’ll be asked for your name and password – this is admin plus whatever you set up on the Website > Web Domain > Statistics tab.
     
    Last edited: Oct 22, 2010
  2. linus3x

    linus3x New Member

    One More Thing...

    By the way, I should add to this that the nightly cron job takes the added step of renaming the awstats.yourdomain.com.html file to index.html so that you can access the stats using:

    Code:
    http://www.[B]yourdomain.com[/B]/stats/
    So if wanted to completely mimic the nightly cron job, you'd run something like:

    Code:
    mv /var/www/clients/client1/web1/web/stats/awstats.[B]yourdomain.com[/B].html /var/www/clients/client1/web1/web/stats/index.html
     
  3. Works like a charm! Thank you so much. For some reason, when switching from Webalizer to AWStats, cron wasn't updating the data properly. But it most definitely works 'manually', precisely as you've explained. And yes, I know this is a 6-year-old thread, but it's comfortable to know that things haven't changed in the way ISPConfig is set up :) (I just love predictability!)
     
  4. tvlahovski

    tvlahovski New Member

    This is great. I only have one issue. The file awsindex.html is always created/updated with owner root:root and not with the correct owner. Something like web1:client1
    I really have no idea where to look for.

    Any suggestions?

    Cheers,
    -Tiho
     
    Last edited: Aug 1, 2016

Share This Page