六、awstats 执行日志分析
在上面的我们讲解了awstats的yum安装与源码安装,同时配置了一个监控实例,下面我们就执行一下这个监控实例www.test.com。
1.现在我们需要用awstats来生成对apache日志的统计分析信息。由于我们用的awstats是支持perl的FCGI动态化访问页面,所以此处我们只需要直接更新数据库即可。FCGI程序会自动将数据库以动态页面的形式展现出来,无须再手动生成静态页面了。
[root@node6 ~]# /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.test.com
Create/Update database for config "/etc/awstats/awstats.www.test.com.conf" by AWStats version 7.2 (build 1.992)
From data in log file "/log/www/access_20131228.log"...
Phase 1 : First bypass old records, searching new record...
Direct access to last remembered record has fallen on another record.
So 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: 155446
Found 8 dropped records,
Found 0 comments,
Found 0 blank records,
Found 1 corrupted records,
Found 0 old records,
Found 155437 new qualified records.
2.查看一下awstats数据库文件
123 [root@web ~]# cd /var/lib/awstats/
[root@web awstats]# ls
awstats122013.www.test.com.txt
3.接下来我们来查看一下分析结果
注,如果,你顺利的执行了上面的所有操作。那么OK,现在你已经可以通过访问:http://www.test.com/awstats/awstats.pl?config=www.test.com ,效果如下图:
好了,到这里awstats工具对一个站点的监控(我们这里是www.test.com站点,博友可以根据自己的实际情况进行自定义)就全部配置完成了,下面我们来演示一下awstats工具怎么对多个Web站点进行监控。
七、awstats 进行多站点日志分析
1.站点说明
www.test.com (主站点)
club.test.com (论坛)
2.配置多站点监控
注,配置club.test.com的配置文件,步骤和上面www.test.com一样,只是在域名的地方做更改即可。下面我们就再来演示一下,
[root@node6 ~]# cd /usr/local/awstats/tools/
[root@node6 tools]# ./awstats_configure.pl
此时会出现如下提示,
----- AWStats awstats_configure 1.0 (build 1.9) (c) Laurent Destailleur -----
This tool will help you to configure AWStats to analyze statistics for
one web server. You can try to use it to let it do all that is possible
in AWStats setup, however following the step by step manual setup
documentation (docs/index.html) is often a better idea. Above all if:
- You are not an administrator user,
- You want to analyze downloaded log files without web server,
- You want to analyze mail or ftp log files instead of web log files,
- You need to analyze load balanced servers log files,
- You want to 'understand' all possible ways to use AWStats...
Read the AWStats documentation (docs/index.html).
-----> Running OS detected: Linux, BSD or Unix
-----> Check for web server install
Enter full config file path of your Web server.
Example: /etc/httpd/httpd.conf
Example: /usr/local/apache2/conf/httpd.conf
Example: c:\Program files\apache group\apache\conf\httpd.conf
Config file path ('none' to skip web server setup):
> /usr/local/apache2/conf/httpd.conf
Your web server config file(s) could not be found.
You will need to setup your web server manually to declare AWStats
script as a CGI, if you want to build reports dynamically.
See AWStats setup documentation (file docs/index.html)
-----> Update model config file '/usr/local/awstats/wwwroot/cgi-bin/awstats.model.conf'
File awstats.model.conf updated.
-----> Need to create a new config file ?
Do you want me to build a new AWStats config/profile
file (required if first install) [y/N] ? y
-----> Define config file name to create
What is the name of your web site or profile analysis ?
Example: www.mysite.com
Example: demo
Your web site, virtual server or profile name:
> club.test.com #我们这里配置域名就是club.test.com,其它地方与www.test.com没有什么不同。
-----> Define config file path
In which directory do you plan to store your config file(s) ?
Default: /etc/awstats
Directory path to store config file(s) (Enter for default):
> #这里要填写你配置文件存放路径,我们使用它默认的路径/etc/awstats,所以直接回车即可。
-----> Create config file '/etc/awstats/awstats.www.test.com.conf'
Config file /etc/awstats/awstats.www.test.com.conf created.
-----> Add update process inside a scheduler
Sorry, configure.pl does not support automatic add to cron yet.
You can do it manually by adding the following command to your cron:
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.test.com
Or if you have several config files and prefer having only one command:
/usr/local/awstats/tools/awstats_updateall.pl now
Press ENTER to continue... #提示不能自动加入crontab定时任务,需要稍后自己添加,我们按回车继续即可。
A SIMPLE config file has been created: /etc/awstats/awstats.www.test.com.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for 'www.test.com' with command:
> perl awstats.pl -update -config=www.test.com
You can also build static report pages for 'www.test.com' with command:
> perl awstats.pl -output=pagetype -config=www.test.com
Press ENTER to finish... #提示配置文件创建完成和如何更新配置及建立静态报告页,这里我们回车即可结束这个配置向导。

好了,下面我们看一下我们生成的配置文件。
3.查看一下生成的配置文件
[root@node6 ~]# cd /etc/awstats/
[root@node6 awstats]# ls
awstats.club.test.com.conf awstats.www.test.com.conf
好了,下面步骤和上面www.test.com配置步骤一样,我这里就不重复说明。下面我们说一下,在使用awstats工具过程中出现的一些小问题。
