笔记 by 车东

AWStats的自定义扩展统计:Using the Extra Sections features

· 日志分析|AWStats

📌 TLDR

AWStats 的 ExtraSection 六种用法,正好覆盖常见的自定义统计需求:跟踪下订单的参数(productid)、最常被访问的 Bugzilla bug(同理可做 BBS 热门帖)、出口点击(链接先经 awredir.pl?url=…)、中断的下载(用 206 状态码筛)、最常用的域名别名(自定义日志字段)、以及某目录下二级目录的 TOP 文章。作者用最后一招做了 /tech 与 /blog 两个目录的 TOP 文章榜。

如何利用AWStats针对网站自身应用进行特定参数的统计,今天学习了一下:AWStats Documentation - Using the Extra Sections features。文档中主要有以下几个例子:

Example 1: Tracking Product orders

跟踪商品订单:解析出GET /cgi-bin/order.cgi?productid=49&session=A0B1C2 中的productid=字段

Example 2: Tracking Bugzilla most frequently viewed bugs

跟踪bugzilla中最经常被访问的Bug:原理同上,这在内部开发中非常有用,类似的,也很容易给BBS系统配置出最常访问的论坛等统计。

Example 3: Tracking Exit clicks

跟踪用户离开当前网站的点击:前提是你将所有指向其他网站的链接通过/cgi-bin/awredir.pl?url=http://externalsite/pagelinked这样的链接进行部署。

Example 4: Tracking aborted download

跟踪中断的下载:利用的是HTTP返回的状态码206 ExtraSectionCodeFilter1=“206”

Example 5: Tracking most requested domain aliases

跟踪最常用的域名别名:这需要在日志中部署并定义扩展字段%your_extra_field,然后在ExtraSestion中部署统计相应的扩展字段%your_extra_field 这里的例子就是将域名的别名,在一个域名有多个别名的时候,分析那个域名最常用最有帮助。

Example 6: List of top level 2 path under a directory /mydir

跟踪某个目录下最常访问的2级子目录,根据样例设置了一个 /tech /blog 2个目录下的TOP文章统计。

增加的配置如下 ExtraSectionName1=“Top aticles under /tech” ExtraSectionCodeFilter1=“200 304” ExtraSectionCondition1=“URL,^/tech/.*” ExtraSectionFirstColumnTitle1=“Article Name” ExtraSectionFirstColumnValues1=“URL,^/tech/([\w]+).html” ExtraSectionFirstColumnFormat1="%s" ExtraSectionStatTypes1=PHL MaxNbOfExtra2=20 MinHitExtra2=1 样例输出:

Article Name 网页数 文件数 最近参观日期
awstats 80 80 2005年 十一月 27日 13:20
google 49 49 2005年 十一月 27日 13:13
google_url 42 42 2005年 十一月 27日 13:12
cvs_card 36 36 2005年 十一月 27日 13:24
lucene 30 30 2005年 十一月 27日 13:22
cms 26 26 2005年 十一月 27日 13:11
link_pop_check 25 25 2005年 十一月 27日 13:13
apache_install 24 24 2005年 十一月 27日 13:13
google_ads 21 21 2005年 十一月 27日 13:16
weblucene 18 18 2005年 十一月 27日 13:13
indent_tools 18 18 2005年 十一月 27日 12:57
cache 17 17 2005年 十一月 27日 13:17
hello_unicode 14 14 2005年 十一月 27日 13:18
study 12 12 2005年 十一月 27日 13:29
resin 11 11 2005年 十一月 27日 13:20
rotate_merge_log 11 11 2005年 十一月 27日 12:02
mysql 11 11 2005年 十一月 27日 13:02
ant 9 9 2005年 十一月 27日 12:40
xslt 8 8 2005年 十一月 27日 12:55
weblog 8 8 2005年 十一月 27日 12:34
ExtraSectionName2="Top aticles under /blog/archives/"
ExtraSectionCodeFilter2="200 304"
ExtraSectionCondition2="URL,^\/blog\/archives\/.*"
ExtraSectionFirstColumnTitle2="Article Name"
ExtraSectionFirstColumnValues2="URL,^\/blog\/archives\/([\d]+)\.html"
**ExtraSectionFirstColumnFormat2="[%s](/blog/archives/%s.html)"**
ExtraSectionStatTypes2=PHL
MaxNbOfExtra2=20
MinHitExtra2=1
Article ID 网页数 文件数 最近参观日期
000432 43 43 2005年 十一月 27日 13:14
000741 39 39 2005年 十一月 27日 13:23
001065 38 38 2005年 十一月 27日 13:28
001070 38 38 2005年 十一月 27日 13:27
001071 38 38 2005年 十一月 27日 13:26
001058 31 31 2005年 十一月 27日 12:58
000825 19 19 2005年 十一月 27日 13:28
000728 16 16 2005年 十一月 27日 13:17
000772 15 15 2005年 十一月 27日 12:33
000515 15 15 2005年 十一月 27日 13:26
000638 15 15 2005年 十一月 27日 13:25
000950 14 14 2005年 十一月 27日 13:09
001060 13 13 2005年 十一月 27日 12:52
000878 13 13 2005年 十一月 27日 12:45
000655 11 11 2005年 十一月 27日 12:24
000790 11 11 2005年 十一月 27日 13:26
000945 11 11 2005年 十一月 27日 13:29
000661 11 11 2005年 十一月 27日 11:55
000651 11 11 2005年 十一月 27日 09:57
000646 11 11 2005年 十一月 27日 13:24

改进建议: 目前的扩展输出能够统计出ID,但是要点击回原有的链接还是很麻烦,希望AWStats能提供相应的模板,让统计出来的ID能还原回URL,以方便点击反查。当然AWStats本身也提供了CSV/XML等格式的输出,可以自己做一些统计扩展来实现这些功能。 发现了一个样例,解决了。

# 注释:统计列说明,在ExtraSectionStatTypes中只有PHBL这几个字段有效
# U = Unique visitors
# V = Visits
# P = Number of pages
# H = Number of hits (or mails)
# B = Bandwith (or total mail size for mail logs)
# L = Last access date
# E = Entry pages
# X = Exit pages
# C = Web compression (mod_gzip,mod_deflate) 

AWStats统计工具安装和配置: http://chedong.com/tech/awstats.html

和MT/WP这些发布系统一样,AWStats也是非常适合中小网站的统计系统。虽然速度和效率上不如WebAlizer/Analog (AWStats在统计百万级访问量的网站时已经很吃力了),但是AWStats所提供的功能却是WebAlizer/Analog远远不及的。所以遇到效率问题的时候,解决的方法不一定是如何找到效率更高的千万级的网站统计系统,将网站分解成多个子频道也是一个可行的办法。

2009-12-22更新: 有道,搜狗,MSN,搜搜,Google,百度和雅虎蜘蛛的统计代码:

ExtraTrackedRowsLimit=20000

ExtraSectionName1="OutfoxBot/YoudaoBot crawls - Top 20"
ExtraSectionCodeFilter1="200 304"
ExtraSectionCondition1="UA,(.*Youdao.*)"
ExtraSectionFirstColumnValues1="URL,(.*)"
ExtraSectionFirstColumnFormat1="[%s](%s)"
ExtraSectionStatTypes1=HBL
MaxNbOfExtra1=20
MinHitExtra1=1

ExtraSectionName2="Sogou crawls - Top 20"
ExtraSectionCodeFilter2="200 304"
ExtraSectionCondition2="UA,(.*Sogou.*)"
ExtraSectionFirstColumnValues2="URL,(.*)"
ExtraSectionFirstColumnFormat2="[%s](%s)"
ExtraSectionStatTypes2=HBL
MaxNbOfExtra2=20
MinHitExtra2=1

ExtraSectionName3="MSN crawls - Top 20"
ExtraSectionCodeFilter3="200 304"
ExtraSectionCondition3="UA,(.*msnbot.*)"
ExtraSectionFirstColumnValues3="URL,(.*)"
ExtraSectionFirstColumnFormat3="[%s](%s)"
ExtraSectionStatTypes3=HBL
MaxNbOfExtra3=20
MinHitExtra3=1

ExtraSectionName4="Sosospider crawls - Top 20"
ExtraSectionCodeFilter4="200 304"
ExtraSectionCondition4="UA,(.*Sosospider.*)"
ExtraSectionFirstColumnValues4="URL,(.*)"
ExtraSectionFirstColumnFormat4="[%s](%s)"
ExtraSectionStatTypes4=HBL
MaxNbOfExtra4=20
MinHitExtra4=1

ExtraSectionName5="Google crawls - Top 20"
ExtraSectionCodeFilter5="200 304"
ExtraSectionCondition5="UA,(.*Google.*)"
ExtraSectionFirstColumnValues5="URL,(.*)"
ExtraSectionFirstColumnFormat5="[%s](%s)"
ExtraSectionStatTypes5=HBL
MaxNbOfExtra5=20
MinHitExtra5=1

ExtraSectionName6="Baidu crawls - Top 20"
ExtraSectionCodeFilter6="200 304"
ExtraSectionCondition6="UA,(.*Baidu.*)"
ExtraSectionFirstColumnValues6="URL,(.*)"
ExtraSectionFirstColumnFormat6="[%s](%s)"
ExtraSectionStatTypes6=HBL
MaxNbOfExtra6=20
MinHitExtra6=1

ExtraSectionName7="Yahoo Slurp crawls - Top 20"
ExtraSectionCodeFilter7="200 304"
ExtraSectionCondition7="UA,(.*Slurp.*)"
ExtraSectionFirstColumnValues7="URL,(.*)"
ExtraSectionFirstColumnFormat7="[%s](%s)"
ExtraSectionStatTypes7=HBL
MaxNbOfExtra7=20
MinHitExtra7=1

💬 历史评论

以下 6 条评论从旧版 Movable Type 博客迁移而来。 原始评论时间:2002–2016 年。

小小弟 · 2006-04-12 17:21

东哥: 我的win2k+resin+awstats是否也能实现自定义扩展统计, 请教一下!!!


helen · 2006-06-14 13:43

你好,车东,前不久曾经请教过你关于AWStats的问题,我们的网站原先装有AWStats,一切正常,4月份21日起网页上所有数据都变为了0。今天我看了下日志文件,发现4.21日后的log文件中的日期都变成了2006-6-30,时间都为03:28:14,我复制了三行内容如下,而之前的都与当日日期相符,并且时间从00:00到24:00,不知这个是什么原因,应该怎么解决?希望你能帮帮我,谢谢了!

“#Fields: date time cs-method cs-uri-stem cs-username c-ip cs-version cs(User-Agent) cs(Referer) sc-status sc-bytes cs-bytes

2006-06-30 03:28:14 GET /Default.aspx - 61.183.16.53 HTTP/1.1 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1) http://ent.sina.com.cn/y/2006-05-21/01381088342.html 200 19138 270

2006-06-30 03:28:14 GET /lycos.css - 61.183.16.53 HTTP/1.1 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1) http://www.marvelon.com.cn/ 200 16777 254

2006-06-30 03:28:14 GET /js/textfloat.js - 61.183.16.53 HTTP/1.1 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5


woyo · 2006-10-19 13:32

你好,车东: 请教一下,awstats可不可以对某段url,如www.localhost.com/test,单独配一个配置文件进行统计,使他出来的统计信息和统计某个域名www.localhost.com效果一样。


chinetman · 2008-09-04 10:26

车东兄,我的Extra Sections features需要统计一个汉字,但是无论如何它都不支持浪个办? linux系统local=utf8,打开了LoadPlugin=“decodeutfkeys,搜索引擎都能正常显示汉字的说。我就简单的按照ex1上面的: ExtraSectionName2=“Product orders” ExtraSectionCodeFilter2=“200 304” ExtraSectionCondition2=“URL,/s/download” ExtraSectionFirstColumnTitle2=“kerword” ExtraSectionFirstColumnValues2=“QUERY_STRING,keyword=([^&]+)” ExtraSectionFirstColumnFormat2="%s” ExtraSectionStatTypes2=P ExtraSectionAddAverageRow2=0 ExtraSectionAddSumRow2=0 MaxNbOfExtra2=20 MinHitExtra2=10

但是结果是不能统计出汉字来, 但是如果我修改用数字的 #ExtraSectionFirstColumnValues2=“QUERY_STRING,pid=([^&]+)” 就能统计出一个结果来的

浪个办啊


donghao · 2009-12-22 15:29

隔了快一年了,终于有新文了


涂鸦 · 2010-02-07 14:19

说的不错。有关于统计扩展的专业文章么?