linux下日志监控分析工具awstat的安装与使用

awstat的功能:

   AWStats是在Sourceforge上发展很快的一个基于Perl的WEB日志分析工具。它可以统计您站点的如下信息:
  一:访问量,访问次数,页面浏览量,点击数,数据流量等
  二:精确到每月、每日、每小时的数据
  三:访问者国家
  四:访问者 IP
  五: Robots/Spiders的统计
  六:纺客持续时间
  七:对不同 Files type 的统计信息
  八: Pages-URL的统计
  九:访客操作系统浏览器等信息
  十:其它信息(搜索关键字等等)
下面开始介绍awstats的安装:(安装包请读者自行下载)
安装之前首先启动 apache,并查看进程(在之前的实验里,我们将其设为了开机启动,所以就不在start了,或者执行restart也可以)
[root@localhost ~]# netstat -tupln|grep http
tcp         0      0 :::80                       :::*                        LISTEN      3787/httpd         
You have new mail in /var/spool/mail/root
[root@localhost ~]#
 
解压包到 /usr/local/awstats目录下
[root@localhost ~]# tar zxvf awstats-7.1.1.tar.gz -C /usr/local/awstats
确定系统已经安装 perl
[root@localhost ~]# whereis perl
perl: /usr/bin/perl /usr/share/man/man1/perl.1.gz
[root@localhost ~]#
编译 awstats:(进入/usr/local/awstats/awstats-7.1.1/tools/目录下)
 [root@localhost ~]# cd /usr/local/awstats/awstats-7.1.1/tools/
[root@localhost tools]# perl awstats_configure.pl
#如果系统已安装 apache的话,自动会检测到配置文件
----- 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
Warning: AWStats standard directory on Linux OS is '/usr/local/awstats'.
If you want to use standard directory, you should first move all content
of AWStats distribution from current directory:
/usr/local/awstats/awstats-7.1.1
to standard directory:
/usr/local/awstats
And then, run configure.pl from this location.
Do you want to continue setup from this NON standard directory [yN] ? y
 
-----> Check for web server install
 Found Web server Apache config file '/etc/httpd/httpd.conf'
 
-----> Check and complete web server config file '/etc/httpd/httpd.conf'
Warning: You Apache config file contains directives to write 'common' log files
This means that some features can't work (os, browsers and keywords detection).
Do you want me to setup Apache to write 'combined' log files [y/N] ? y
 Add 'Alias /awstatsclasses "/usr/local/awstats/awstats-7.1.1/wwwroot/classes/"'
 Add 'Alias /awstatscss "/usr/local/awstats/awstats-7.1.1/wwwroot/css/"'
 Add 'Alias /awstatsicons "/usr/local/awstats/awstats-7.1.1/wwwroot/icon/"'
 Add 'ScriptAlias /awstats/ "/usr/local/awstats/awstats-7.1.1/wwwroot/cgi-bin/"'
 Add '<Directory>' directive
 AWStats directives added to Apache config file.
 
-----> Update model config file '/usr/local/awstats/awstats-7.1.1/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:
> AnalyzeApacheLog
 
-----> 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):
>              (直接回车,默认就好)
 
-----> Create config file '/etc/awstats/awstats.AnalyzeApacheLog.conf'
 Config file /etc/awstats/awstats.AnalyzeApacheLog.conf created.
 
-----> Restart Web server with '/sbin/service httpd restart'
停止 httpd:                                               [确定]
启动 httpd:                                               [确定]
 
-----> 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/awstats-7.1.1/wwwroot/cgi-bin/awstats.pl -update -config=AnalyzeApacheLog
Or if you have several config files and prefer having only one command:
/usr/local/awstats/awstats-7.1.1/tools/awstats_updateall.pl now
Press ENTER to continue...
 
 
A SIMPLE config file has been created: /etc/awstats/awstats.AnalyzeApacheLog.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for 'AnalyzeApacheLog' with command:
> perl awstats.pl -update -config=AnalyzeApacheLog
You can also read your statistics for 'AnalyzeApacheLog' with URL:
> http://localhost/awstats/awstats.pl?config=AnalyzeApacheLog
 
Press ENTER to finish...
 
[root@localhost tools]#
查看配置文件:
[root@localhost tools]# vim /etc/awstats/awstats.AnalyzeApacheLog.conf
LogFile="/var/log/httpd/mylog.log"(默认的存放路径)
注:
1)如果同时分析多个日志
LogFile="/opt/awstats/tools/logresolvemerge.pl /var/apachelogs/30.0206.vblog.log /var/apachelogs/31.0206.vblog.log|"
LogFile="/opt/awstats/tools/logresolvemerge.pl /var/apachelogs/*.0206.vblog.log|"
 
(2)分析使用 gzip压缩过的日志文件
LogFile="gzip -d </var/log/apache/access.log.gz|"
 
 

你可能感兴趣的:(linux,awstats,日志监控分析)