每天丢掉一点统计数据

不恰当的日志统计设置,可能会导致每天丢掉一部分日志统计数据,请看我犯过的错误。  我使用awstats 统计日志数据,在config 文件中,我设定如下参数: LogFile="/home/username/logs/aiview.com/http/access.log" 我在crontab 中设定每天在整点每间隔4个小时运行一次统计更新。 00 0-23/4 * * * ~/jobs/updawt.sh 我的空间在Dreamhost ,日志生成情况如下,包含当天,一共有最近6天的日志文件,当天的命名为...

不恰当的日志统计设置,可能会导致每天丢掉一部分日志统计数据,请看我犯过的错误。 

我使用awstats 统计日志数据,在config 文件中,我设定如下参数:

LogFile="/home/username/logs/aiview.com/http/access.log"

我在crontab 中设定每天在整点每间隔4个小时运行一次统计更新。

00 0-23/4 * * * ~/jobs/updawt.sh  

我的空间在Dreamhost ,日志生成情况如下,包含当天,一共有最近6天的日志文件,当天的命名为 access.log,前五天加日期后缀,最早的4天压缩存储,第五天不压缩。同时为第五天的日志建立了一个名为access.log.0 的符号连接。

-rw-r--r--  1 root       root      1830112 Apr 16 22:03 access.log
lrwxrwxrwx  1 root       root           21 Apr 16 01:03 access.log.0 -> access.log.2007-04-15
-rw-r--r--  1 xxx        xxx       255078 Apr 11 00:50 access.log.2007-04-10.gz
-rw-r--r--  1 xxx        xxx       222179 Apr 12 00:58 access.log.2007-04-11.gz
-rw-r--r--  1 xxx        xxx       214981 Apr 13 00:07 access.log.2007-04-12.gz
-rw-r--r--  1 xxx        xxx       150369 Apr 14 00:13 access.log.2007-04-13.gz
-rw-r--r--  1 root       root      1096740 Apr 16 01:03 access.log.2007-04-15 

我在配置文件中指定的文件名是access.log ,从前,我一直以为awstats 会自动合并access.log.[0-9],也包括这里的access.log.0 ,但刚刚发现,awstats 并不做这件事情,除非详细指定。

结果就是,我会丢失从日志文件发生轮换那一刻起,至最后一次统计更新之间的那部分日志的统计数据,因为它们没有获得被统计的机会,就被重命名为access.log.0 。而依据我的设置,access.log.0 并不在统计范围。

这里还有一些细节,统计数据是否会丢,以及会丢掉多少,还取决于日志轮换的具体时间(并不总是发生在零点),以及我的job 执行间隔与执行时间。无论如何,更改配置文件,使其不依赖于这些不确定因素是好的方法。

我修改了我的统计配置文件如下:

#LogFile="/home/username/logs/aiview.com/http/access.log"
LogFile="./tools/logresolvemerge.pl /home/username/logs/aiview.com/http/access.log /home/username/logs/aiview.com/http/access.log.0 |" 

logresolvemerge.pl 随awstats 程序包提供,你需要指定适用你的正确路径。 

 

mail.png


标签订阅|Tag Subscription

If you use an RSS reader, you can subscribe to a feed of all future entries tagged 'awstats,日志统计'. [What is this?]

Subscribe to feed Subscribe to feed

最近更新|Recent Entries

不定期更新|Handy Entries

其它标签|Other Tags

分类栏目|Categories

按月归档|By Month

2008
11
10
07
05
04
03
02
01
2007
12
10
07
06
05
04
03
02
01
2006
12
11
10
09
08
07
06
05
04
03
02
01
2005
11
10
09
08
07
04
03
2004
12
11
10
09
08
07
06
05
04
03
02
01
2003
12
10
09
08
06
2002
09
08
04
03
02
2001
12
09
07
06
05

站内链接|Site Links

Powered by
Movable Type 3.34