Entries tagged with “Awstats” from DBA notes
配置好 Nginx 后,可能有的朋友还想用 Awstats 分析日志。如果另外再起一个 Apache ,觉得费二遍事。如果在 Nginx 上跑 Awstats ,还需要 FASTCGI 支持。配置的方法有些山寨。Nginx 尽管提供 Perl 模块支持,毕竟还是实验性质的。
对比了一些文章,决定还是用 nginx-fcgi 这个脚本。作者是 Daniel Dominik Rudnicki 。这个脚本要比顺子文中提到的要好一点。
该脚本中用到如下的 Perl 模块。所以使用前要确保相关 Perl 模块已经存在。要不,手工下载安装一下。
- perl-FCGI
- perl-Getopt
- perl-IO
- perl-Socket
使用命令示意:
/usr/local/nginx/nginx-fcgi -S /tmp/fastcgi.sock -l /var/log/nginx/nginx-fcgi.log
-pid /var/run/nginx-fcgi.pid
网上常见的那个脚本必须要显示的指定最为后台进程跑。不是很完善的方法。
注意事项:不能用 root 用户执行(会提示). 要用与 Nginx 相同身份的用户执行。否则可能会在 Nginx Log 中提示 Permision Denied 。
Nginx 中配置好 Log 格式:
log_format main '$remote_addr - [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer"'
'"$http_user_agent" $http_x_forwarded_for';
相对应的 Awstats 中 Log 格式为:
LogFormat = "%host - %time1 %methodurl %code %bytesd %refererquot %uaquot"
其他的配置参考一下Sunnyu 的 "为了Awstats给Nginx添加FastCGI方式的Perl支持" 应该就成了。
BTW: 应该说,Nginx 能够有效抵挡搜索引擎爬虫对网站的影响。对于 Apache 来说,这是个很大的进步。
--EOF--
更新:如果手工写脚本做 Nginx 日志 logrotate 的话,注意不要简单的用 mv 命令, cp 然后 echo ''> 的方式更好。
推荐: Sina 张宴的 Nginx 0.7.x + PHP 5.2.6(FastCGI)搭建胜过Apache十倍的Web服务器(第4版),这是目前关于 Nginx 最详细的实践文章。
刚在邮件列表里看到通知,AWstats 发布了 6.8 Beta 版。
和上一次更新相比,新版本增加了特性不多:
Added OnlyUsers option.
Can show a full list for extrasection.
Can track RPC request.
如果要定制跟踪额外的访问信息,Extrasection 总是绕不过去的。还没测试这个版本,倒是希望这部分内容的配置能更清晰容易一些。
值得一提的是浏览器数据库的更新与 Patch 几乎都是中文搜索引擎与 Web 应用的爬虫相关,据我所知车东同学做了不少这方面的工作。
BTW: AWstats 堪称中小站点分析日志的不二之选。尽管这样,前段时间还是看到有些公司居然不了解这个好用的工具,嗯,推广之。
--EOF--
邮件列表里看到的消息。AWStats 6.7 正式版发布了。新特性/改进列表:
- Full support for -day option. To build different report for each day - Added virtualenamequot tag - Added option NotPageList - Addes .jobs and .mobi domains
对于第一条,按日构建报告其实从 6.5 版本以后就提供了相关功能。6.7 版本说是 "Full Support",没看明白怎么个 "Full"。更多内容可以参考车东的AWStats的千万级日志解决方案。
--EOF--
从后台日志上观察到有大量来自 114.com.cn 的搜索。最开始没有注意,还以为是 VNet 过来的--都有个 114 嘛。这两天查询突然暴增,仔细一看,还真不是一回事:
$ grep 114.com.cn access.log |awk '{print substr($11,1,80)}' |head
"http://so.114.com.cn/usearchp?keyword=\xd4\xbd\xd3\xfc\xb5\xda\xb6\xfe\xbc\xbe&
"http://so.114.com.cn/usearchp?keyword=\xd4\xbd\xd3\xfc\xb5\xda\xb6\xfe\xbc\xbe&
"http://so.114.com.cn/usearchp?keyword=\xd4\xbd\xd3\xfc\xb5\xda\xb6\xfe\xbc\xbe&
"http://so.114.com.cn/usearchp?keyword=\xd4\xbd\xd3\xfc\xb5\xda\xb6\xfe\xbc\xbe&
"http://so.114.com.cn/usearchp?keyword=\xd4\xbd\xd3\xfc\xb5\xda\xb6\xfe\xbc\xbe&
"http://so.114.com.cn/usearchp?logo=1&keyword=\xd4\xbd\xd3\xfc\xb5\xda\xd2\xbb\x
"http://so.114.com.cn/usearchp?logo=1&keyword=\xd4\xbd\xd3\xfc\xb5\xda\xd2\xbb\x
"http://so.114.com.cn/usearchp?keyword=\xd4\xbd\xd3\xfc\xb5\xda\xb6\xfe\xbc\xbe&
"http://so.114.com.cn/usearchp?keyword=\xd4\xbd\xd3\xfc\xb5\xda\xb6\xfe\xbc\xbe&
"http://so.114.com.cn/usearchp?keyword=\xd4\xbd\xd3\xfc\xb5\xda\xb6\xfe\xbc\xbe&
为了节省空间,没有把 URL 都打出来,所用的参数极为诡异,后面还有几个奇怪的参数,AWstats 也根本不能探测到引用的关键词是什么。
搜索了一下,这个站点叫"中国网上黄页", 是厦门的一家叫什么"中资源"的公司做的。
添加了一下这个搜索引擎的定义,暂时叫他 '114' 吧. 添加定义挺简单的,我做的修改:
$ diff search_engines.pm search_engines.pm.backup1003
192d191
< '114\.com\.cn',
366d364
< '114\.com\.cn','114',
578d575
< '114','keyword=',
754d750
< '114','114',
观察到的效果:
| 来自搜索引擎 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
感觉国内的个别搜索引擎根本不关心什么规范之类的事情,Bot 随便爬,爱咋咋地的态度。
--EOF--
如何统计站点中下载次数最多的文件? 从 Antezeta 学来一招,在配置文件中添加一段 ExtraSection ,类似如下:
ExtraSectionName10="Downloads (doc,rar,sql,pdf,sh,tgz,zip) - Top 10" ExtraSectionCodeFilter10="200 304" ExtraSectionCondition10="URL,(.*((\.doc)|(\.rar)|(\.sql)|(\.pdf)| \ (\.sh)|(\.tgz)|(\.zip)))" ExtraSectionFirstColumnTitle10="Download" ExtraSectionFirstColumnValues10="URL,(.*)" ExtraSectionFirstColumnFormat10="%s" ExtraSectionStatTypes10=HBL ExtraSectionAddAverageRow10=0 ExtraSectionAddSumRow10=1 MaxNbOfExtra10=10 MinHitExtra10=1
可以添加或减少需要匹配的文件类型。
有朋友问我 Blog 首页下方的"最多阅读的文章"如何得到的,其实也是用 Awstats 得到的数据。细节内容请参考:AWStats Enhancements and Extensions。
另外,根据 添加 egosurf 页面 的思路,又添加了在线书签的页面。不过遇到一个非常奇怪的原因。非常奇怪...
无独有偶,在后台 web 服务器的错误访问日志上也观察到很奇怪的现象,奇怪,非常非常奇怪 @*%*$$&*.....ooooooops
以下为 2005 年本站迁移到 DreamHost 提供的虚拟主机上之后,建立起来的 Awstats 抓到的近三个月左右的统计数据.不同的搜索引擎的"贡献度"如下:
| 转介参观者到本站的搜索引擎 | 网页数 | 百分比 | 文件数 | 百分比 |
|---|---|---|---|---|
| 29898 | 62.8 % | 29935 | 57.6 % | |
| Baidu | 14637 | 30.7 % | 16958 | 32.6 % |
| 679 | 1.4 % | 695 | 1.3 % | |
| Google (Images) | 625 | 1.3 % | 884 | 1.7 % |
| MSN | 403 | 0.8 % | 2065 | 3.9 % |
| 3721 | 373 | 0.7 % | 373 | 0.7 % |
| Yahoo | 320 | 0.6 % | 320 | 0.6 % |
| SoGou | 176 | 0.3 % | 176 | 0.3 % |
| YiSou | 133 | 0.2 % | 133 | 0.2 % |
| NetEase | 123 | 0.2 % | 123 | 0.2 % |
| ZhougSou | 46 | 0 % | 46 | 0 % |
| Unknown search engines | 40 | 0 % | 102 | 0.1 % |
| Sina | 27 | 0 % | 27 | 0 % |
| Alexa | 17 | 0 % | 17 | 0 % |
| iask | 16 | 0 % | 16 | 0 % |
| 21CN | 7 | 0 % | 7 | 0 % |
| Netscape | 7 | 0 % | 7 | 0 % |
| Dogpile | 5 | 0 % | 5 | 0 % |
| A9.com | 5 | 0 % | 6 | 0 % |
| MetaCrawler (Metamoteur) | 5 | 0 % | 5 | 0 % |
| Tom | 4 | 0 % | 5 | 0 % |
| Excite | 4 | 0 % | 5 | 0 % |
| Ask Jeeves | 3 | 0 % | 3 | 0 % |
| Kvasir | 3 | 0 % | 3 | 0 % |
| AOL | 2 | 0 % | 2 | 0 % |
| WebCrawler | 1 | 0 % | 1 | 0 % |
| Hotbot | 1 | 0 % | 1 | 0 % |
| Mamma | 1 | 0 % | 1 | 0 % |
| AOL (de) | 1 | 0 % | 1 | 0 % |
| AltaVista | 1 | 0 % | 6 | 0 % |
| metacrawler.de | 1 | 0 % | 1 | 0 % |
| Looksmart | 1 | 0 % | 1 | 0 % |
| Sohu | 1 | 0 % | 1 | 0 % |
| Rambler | 1 | 0 % | 1 | 0 % |
| China | 1 | 0 % | 1 | 0 % |
