Blog | Phodal - A Growth Engineerhttp://www.phodal.com/blog/2015-08-04T01:48:27.206902+00:00Blog网站nginx log分析之使用goaccess 2014-12-04T13:36:35+00:002015-08-04T01:48:27.206902+00:00Phodal Huanghttp://www.phodal.com/blog/author/root/http://www.phodal.com/blog/use-goaccess-analyse-nginx-log/最近无聊的时候,觉得应该分析一下Nginx的Log。
-rw-r--r-- 1 fdhuang staff 139M Dec 3 23:16 access.log
猛然间才发现原来这个文件已经有了139M了。于是,用迅雷把文件下了下来。开始寻找分析的工具,这时找到了GoAccess。
##GoAccess
> GoAccess是一款开源、实时,运行在命令行终端下的web日志分析工具。该工具提供快速、多样的HTTP状态统计,可以令管理员不再纠结于统计各类数据,和繁杂的指令以及一大堆管道/正则表达式说byebye。
###安装GoAccess
因为是Mac OS,这么流行的工具brew一定会有的
brew install goaccess
##分析Nginx Log
运行了下
goaccess -f access.log
出来了,先看看Dashboard
Dashboard - Overall Analyzed Requests [Active Panel: Visitors]
Total Requests 747783 Unique Visitors 73696 Referrers 26613 Log Size 138.94 MiB
Failed Requests 2028 Unique Files 49552 Unique 404 9472 Bandwidth 6.95 GiB
Generation Time 11 Excl. IP Hits 0 Static Files 1140 Log File access.log
发现带宽已经消耗了7G!(AWS试用的总共才15G)。累计请求有``747,783``次,
##GoAccess Hosts
接着看到了下一个数据更是惊呆了
5 - Hosts Total: 300/21766
Top Hosts sorted by hits - [bandwidth] [time served]
31892 4.26% 5.66 MiB 106.185.49.93 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
31350 4.19% 46.37 MiB 182.118.33.8 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
21339 2.85% 249.11 MiB 125.88.219.97 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
21293 2.85% 249.21 MiB 123.125.80.222 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
21288 2.85% 249.29 MiB 180.153.197.58 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
17061 2.28% 152.48 MiB 220.181.125.16 |||||||||||||||||||||||||||||||||||||||||||||||
13907 1.86% 25.22 MiB 188.142.102.190 ||||||||||||||||||||||||||||||||||||||
打开流量比较的两个一看:
Mozilla/5.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322) 360JK yunjiankong
Mozilla/5.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322) 360JK yunjiankong 191242
Mozilla/5.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322) 360JK yunjiankong 205152
光360的网站监控工具就花去了我近``800M``的带宽。
###GoAccess 浏览器
下面是结果
Visitors | % | Name
----------|----------|-------
16259 | 22.06% | Crawlers
14786 | 20.06%| Safari
14442 | 19.60% | Chrome
11923 | 16.18% | MSIE
6546 | 8.88% | Firefox
596 | 0.81% | Opera
于是便觉得不能愉快地玩耍,访问最多的居然是爬虫:
Visitors | % | Name
----------|----------|-------
16259 | 22.06% | Crawlers
7913 | 10.74% | — Baiduspider/2.0
1531 | 2.08% | — Baidu-YunGuanCe-Bot(ce.baidu.com
1462 | 1.98% | — Googlebot/2.1
858 | 1.16% | — bingbot/2.0
824 | 1.12% | — AhrefsBot/5.0
564 | 0.77% | — MJ12bot/v1.4.5
518 | 0.70% | — Googlebot-Mobile/2.1
516 | 0.70% | — YisouSpider
264 | 0.36% | — Sogou
216 | 0.29% | — Google
各式各样的爬虫,最多的是百度,怪不得最近的流量主要是来自百度。
####结论
有意思的是发现,访问我网站很多都是用Safari,其次是Chrome,接着是IE,然后是Firefox,难道是说程序员都开始用Mac OS了么?
###操作系统
看了看操作系统一栏,觉得没有出乎意料。
Visitors | % | Name
----------|----------|-------
30466 | 41.34% | Windows
20901 | 28.36% | Unknown
12109 | 16.43% | Android
5517 | 7.49% | Macintosh
2618 | 3.55% | Unix-like
1984 | 2.69% | Linux