Thursday, October 30, 2014

Configure awstats with apache on solaris


  Introduction : 

awstats

Awstats(Advanced web statistics) is an open source log analyzer. It can analyze a wide variety of logs with different log format of many different web servers. This tool can be configured in both windows and UNIX environments. 

This Log Analyzer works as a CGI or from command line and shows all the possible information that the log contains, in few graphical web pages. It uses a partial information file to be able to process large log files, often and quickly.

Downloading Awstats : 


Awstats can be downloaded from the following URL :

Installing and configuring AWStats on Solaris :


Following are the simple steps to install and configure awstats with Apache logs. 

Step 1 : 


Extract the downloaded awstats (awstats-7.0.tar.gz) using the following command.

gtar -xzf awstats-7.0.tar.gz

The folder awstats-7.0 will be created now.

Step 2 :


Navigate to awstats-7.0/tools and hit the following command.

perl awstats_configure.pl

Following configuration related questions will pop-up.

-> If you want to install the awstats in a customized directory, Then type "y" and hit enter.

 If yes, Then a new awstats configuration file will be created.

-> Enter the name of your application or the profile name. ex : test1

You can give any name that you prefer. This name will be used in the url that is used to access the awstats.

-> Enter the path of the folder, Where the configuration files are to be stored.

This path will contain the awstats.configuration file.

-> After this the screen will exit.

There will a sample config file created in the path chosen during the configuration. We can amend that configuration in sync with our needs.

Step 3 : 


The Main elements to change in the awstats.test1.conf : 

LogFile="/var/log/httpd/mylog.log" 

--> Define the access.log path of the Apache web server.

LogFormat="%host %other %logname %time1 %methodurl %code %bytesd %refererquot %uaquot"               

--> This LogFormat has to be in sync with the Apache logs logging format.

SiteDomain="test1" -- This SiteDomain value will be used in the URL as following.

HostAliases=" 127.0.0.1 localhost <servername>"

--> All other possible domain names, Addresses and ip's that you want to access your site.

DirData="/opt/app/gordon/awstats"

--> When the Awstats updates it statistics, it stores the results of it's analysis in files(Awstats database). All these files will be written to the directory specified in DirData.

AllowToUpdateStatsFromBrowser=1

--> This update will provide a link <update> in the browser, By clicking this link, The Awstats data will be refreshed.



Step 4 : 


Generate the statistics for the first time by using the following command.

perl awstats.pl -config=test1 -update

AWStats will read the configuration file awstats.test1.conf and create or update its database with all summary information issued from analyzed log file.

AWStats statistics database files are saved in directory defined by the DirData parameter in configuration file.

When the create/update is finished, you should see a similar result on your screen :

Update for config "/awstats/awstats.test1.conf"
With data in log file "/pathtothelog/logfile.log"
Phase 1 : First bypass old records, searching new record...
Searching new records from beginning of log file...
Phase 2 : Now process new records (Flush history on disk after 20000 hosts)...
Jumped lines in file: 0
Parsed lines in file: 225570
 Found 125 dropped records,
 Found 97 corrupted records,
 Found 0 old records,
 Found 225321 new qualified records.

Dropped records are records discarded because they were not "user HTTP requests" or were requests matching AWStats filters

Corrupted records are records that do not match the log format defined by the "LogFormat" parameter in the AWStats configuration file.

Old records are simply records that were already processed by a previous update session. Although it is not necessary to purge your log file after each update process, it is highly recommended that you do so as often as possible.

New records are records in your log file that were successfully used to build/update the statistics database.

Step 5 : 


Statistics can now be accessed by using the following url from the browser.

Step 6 : 


The statistics updation script can be added in the cronjob for automatic updation.

40 * * * * /Pathtothescript/update_stat >/dev/null 2>&1

Update_stat will contain the following command : 

perl awstats.pl -config=test1 -update


                                                                         (: Happy learning :)

0 comments:

Post a Comment