awstats分析历史日志的处理办法

来源:互联网 发布:意大利脱欧 知乎 编辑:程序博客网 时间:2024/06/07 10:54

        今天查看awstats访问量统计分析系统时,发现从2013年5月15号就没数据了,查看配置文件发现参数值里指定了日志为5月14日,中间插了5个多月的数据,需要重新分析。

当时就跑了一个昨天(2013.11.5)的日志,跑完后在系统上就能看见昨天的访问量,就是系统里缺少2013.5.15-2013.11.4的数据。但是此时在分析2013.5.15的日志系统是不会显示的。

处理办法:

查看/etc/awstats的配置文件中DataDir配置项为DirData="/logs/awstats"

这个目录下的文件是awstats的网页分析数据,相当于系统的数据库,文件以awstats月份+年份.域名.txt

修改最新的数据文件,找到LastTime项如下

LastTime 20130531175501

LastTime就是日志最晚分析时间,将此项改为2013年5月14日就可以更新5月14号的日志文件了

awstats.pl参数选项如下:

Options to update statistics:  -update        to update statistics (default)  -showsteps     to add benchmark information every 8192 lines processed  -showcorrupted to add output for each corrupted lines found, with reason  -showdropped   to add output for each dropped lines found, with reason  -showunknownorigin  to output referer when it can't be parsed  -showdirectorigin   to output log line when origin is a direct access  -updatefor=n   to stop the update process after parsing n lines  -LogFile=x     to change log to analyze whatever is 'LogFile' in config file  Be care to process log files in chronological order when updating statistics.

下面准备批量分析日志的脚本

将需要分析的日志文明导入loglist文件如下:

logfile
localhost_20130515.loglocalhost_20130516.loglocalhost_20130517.loglocalhost_20130518.loglocalhost_20130519.loglocalhost_20130520.loglocalhost_20130521.loglocalhost_20130522.loglocalhost_20130523.loglocalhost_20130524.loglocalhost_20130525.loglocalhost_20130526.loglocalhost_20130527.loglocalhost_20130528.loglocalhost_20130529.loglocalhost_20130530.loglocalhost_20130531.loglocalhost_20130601.loglocalhost_20130602.loglocalhost_20130603.loglocalhost_20130604.loglocalhost_20130605.loglocalhost_20130606.loglocalhost_20130607.loglocalhost_20130608.loglocalhost_20130609.loglocalhost_20130610.loglocalhost_20130611.loglocalhost_20130612.loglocalhost_20130613.loglocalhost_20130614.loglocalhost_20130615.loglocalhost_20130616.loglocalhost_20130617.log
。。。。。。。

脚本文件getresulet.sh如下:

#!/bin/bashwhile read logfile do   perl  /usr/local/awstats/wwwroot/cgi-bin/awstats.pl  -update -config=localhost -LogFile=/logs/$logfiledone <list1 

执行getresulet.sh成功。

原创粉丝点击