当前位置:文档之家› 运维管理—日志分析工具awstats

运维管理—日志分析工具awstats

AWStats is a free powerful and featureful server logfile analyzer that shows you all your Web/Mail/FTP statistics including visits,unique visitors,pages,hits,rush hours, os,browsers,search engines,keywords,robots visits,broken links and more Drag screenshots to sort.AWStats软件是一个免费的强大的服务器的日志文件分析工具,显示你所有的网页/邮件/ FTP统计包括访问,访问者,页面,点击,高峰时间,操作系统,浏览器,搜索引擎,关键字,机器人访问,断开的链接和更多的阻力截图排序。

三、awstats特点Awstats是在SourceForge上发展很快的一个基于Perl的WEB日志分析工具,一个充分的日志分析让Awstats显示您下列资料:访问次数、独特访客人数,∙访问时间和上次访问,∙使用者认证、最近认证的访问,∙每周的高峰时间(页数,点击率,每小时和一周的千字节),∙域名/国家的主机访客(页数,点击率,字节,269域名/国家检测,geoip检测),∙主机名单,最近访问和未解析的IP地址名单∙大多数看过的进出页面,∙档案类型,∙网站压缩统计表(mod_gzip或者mod_deflate),∙使用的操作系统(每个操作系统的页数,点击率,字节,35OS detected),∙使用的浏览器,∙机器人访问(检测319个机器人),∙蠕虫攻击(5个蠕虫家族),∙搜索引擎,利用关键词检索找到你的地址,∙HTTP协议错误(最近查阅没有找到的页面),∙其他基于URL的个性报导,链接参数,涉及综合行销领域目的.∙贵网站被加入"最喜爱的书签".次数.∙屏幕大小(需要在索引页补充一些HTML标签).∙浏览器的支持比例:Java,Flash,RealG2reader,Quicktime reader,WMA reader, PDF reader.∙负载平衡服务器比率集群报告.Awstats的运行是需要PERL环境的支持,从awstats的文档来看,它对Apache HTTP Server的支持是非常完美的,而当我们把Web服务器换成Nginx后,要运行awstats变得很麻烦。

首先Nginx本身对Perl的支持是比较弱的,甚至官方也不建议使用;另外在日志格式上有需要修改后才能运行。

四、awstats运行原理(1).工作原理AWStats的功能很多,我在此主要用它来分析apache服务器的日志。

安装使用之前还是说说大致的工作原理,AWStats提供一系列的perl脚本实现:服务配置,日志读取,报表生成等功能。

而功能实现的具体执行过程是:首先,当然是apache将访问情况记录到日志中,AWStats每次执行更新时读取这些日志,分析日志数据,将结果存储到数据库中,(这个数据库是AWStats自带的(就是一文本文件),并不需要第三方软件支持。

),最后AWStats 提供一个cgi程序通过web页面来显示数据库中所统计的数据。

(2).工作模式AWStats的工作模式是这样的:分析日志:运行后将这样的日志统计结果归档到一个AWStats的数据库(纯文本)里;输出日志:分两种形式∙一种是通过cgi程序读取统计结果数据库输出(Linux中);∙一种是运行后台脚本将输出导出成静态文件(Windows中);五、awstats安装与配置详解1.环境准备(1).安装yum源[root@node6src]#wget1/fedora/epel/6/i386/epel-release-6-8.noarch.rp2345m[root@node6src]#rpm -ivh epel-release-6-8.noarch.rpmwarning:epel-release-6-8.noarch.rpm:Header V3RSA/SHA256Signature,key ID 0608b895:NOKEY Preparing...###########################################[100%]1:epel-release ###########################################[100%](2).安装cronolog 日志切割工具1234567[root@node6src]#wget/download/cronolog-1.6.2.tar.gz [root@node6src]#tar xf cronolog-1.6.2.tar.gz [root@node6src]#cd cronolog-1.6.2[root@node6cronolog-1.6.2]#./configure[root@node6cronolog-1.6.2]#make &&make install [root@localhost ~]#which cronolog /usr/local/sbin/cronolog2.时间同步123[root@node6src]#yum install -y ntp [root@node6src]#ntpdate 202.120.2.10128Dec 17:59:17ntpdate[1413]:step time server 202.120.2.101offset-25666.776448sec3.安装awstats (1).yum 直接安装1[root@node6~]#yum install -y awstats(2).源码包安装首先,我们要下载awstats 软件包,并将其放在常规目录(/usr/local)下。

12[root@node6src]#wget/project/awstats/AWStats/7.2/awstats-7.2.tar.gz3456[root@node6src]#tar xf awstats-7.2.tar.gz [root@node6src]#mv awstats-7.2/usr/local/awstats [root@node6src]#cd /usr/local/awstats [root@node6awstats]#lsdocs README.TXTtoolswwwroot注,由于wget 下载下来的包中权限是非root 的,所以这里要修改权限,否则稍后*.pl 将无法运行。

1234567891011121314151617[root@node6awstats]#chown -R root.root /usr/local/awstats [root@node6awstats]#ll 总用量20drwx------.4root root 40967月1004:01docs -rw-------.1root root 67907月1003:50README.TXT drwx------.5root root 40967月1004:01tools drwx------.7root root 40967月1004:01wwwroot[root@node6awstats]#chmod +x /usr/local/awstats/tools/*.pl [root@node6awstats]#cd tools/[root@node6tools]#lsawstats_buildstaticpages.pl awstats_exportlib.pl geoip_generator.pl logresolvemerge.plnginxwebminawstats_configure.pl awstats_updateall.pl httpd_confmaillogconvert.pl urlaliasbuilder.pl xslt[root@node6tools]#chmod +x/usr/local/awstats/wwwroot/cgi-bin/*.pl [root@node6tools]#cd ..[root@node6awstats]#cd wwwroot/cgi-bin/[root@node6cgi-bin]#lsawdownloadcsv.pl awredir.pl awstats.model.confawstats.pllang lib plugins(3).接下来,我们要执行/usr/local/awstats/tools 下的awstats_configure.pl 配置向导,用来生成awstats 的配置文件,awstats 配置文件的命名规则是awstats.website.conf。

123456789101112131415161718192021222324252627[root@node6~]#cd /usr/local/awstats/tools/[root@node6tools]#./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 forone web server.You can try to use it to let itdo all that ispossiblein AWStats setup,however following the step by step manual setupdocumentation (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 logfiles,-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----->Checkfor web server installEnter full config file path of your Web server.Example:/etc/httpd/httpd.confExample:/usr/local/apache2/conf/httpd.confExample:c:\Program files\apache group\apache\conf\httpd.conf Configfile path ('none'to skip web server setup):>/usr/local/apache2/conf/httpd.conf #这里让你输入apache 配置文件的目录,我这里的apache 是源码安装的,所以我的路径是/usr/local/apache2/conf/httpd.conf282930313233343536373839404142434445464748495051525354555657Your web server config file(s)could not be found.Youwill need to setup your web server manually todeclare AWStatsscript as a CGI,if you want to build reports dynamically.SeeAWStats setup documentation (file docs/index.html)----->Update modelconfig file '/usr/local/awstats/wwwroot/cgi-bin/awstats.model.conf 'File awstats.model.conf updated.----->Need to create a new configfile ?Do you want me to build a new AWStats config/profilefile (required if first install)[y/N]?y #询问是否创建一个新的配置文件,这里填y 即可。

相关主题