goaccess安装和使用(命令行、网页等)

简介:

goaccess is a free (GPL) real-time web log analyzer and interactive viewer that runs 
in a terminal in *nix systems.It provides fast and valuable HTTP statistics for system
administrators that require a visual server report on the fly.GoAccess parses the 
specified web log file and outputs the data to the X terminal.
是一个用来统计 Apache Web 服务器的访问日志的工具,速度非常快,可即时生成统计报表.

一、Debian下安装goaccess
cat /etc/debian_version 
6.0.10
apt-cache search goaccess
goaccess - log analyzer and interactive viewer for the Apache Webserver
apt-get -y install goaccess

二、Centos下安装goaccess
cat /etc/redhat-release 
CentOS release 6.6 (Final)
yum list|grep goaccess
goaccess.x86_64                            0.8.5-1.el6                   epel
yum -y install goaccess
没有epel源的话需要安装
rpm -Uvh http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm

三、参数说明

-b Enable total bandwidth consumption. To achieve faster parsing, 
do not enable this flag.  This has been disabled by default.(流量统计)
-f input-file path to input log filename(日志文件名)
-s Enable/report HTTP status codes. To avoid overhead while parsing, 
this has been disabled by default.(HTTP响应代码统计)
-e Exclude an IP from being count it under the HOST module. 
This has been disabled by default.(指定IP地址统计,默认禁用)
-c Prompt log/date configuration window.(配置)
-a Enable a List of User-Agents by host.(用户代理统计)

四、功能说明
1、General Statistics(统计概况,流量消耗)
Number  of valid requests, number of invalid requests, time to analyze the data, 
unique visitors, unique requested files, unique static files (css, ico, jpg,
js, swf, gif, png) unique HTTP referrers (URLs), unique 404s (not found), 
size of the parsed log file, bandwidth consumption.
2、Unique visitors(访客排名)
HTTP requests having the same IP, same date and same agent will be considered a 
unique visit. This includes crawlers.
3、Requested files(动态Web请求)
Hit totals are based on total requests. This module will display hits, percent, 
bandwidth [time served], [protocol] and [method].
4、Requested static files(静态web请求,如图片、样式表、脚本等)
Hit totals are based on total requests. Includes files such as: jpg, css, swf, js, 
gif, png etc. 
This module will display hits,percent,bandwidth,[time served],[protocol] and [method].
5、404 or Not Found(404 错误)
Hit totals are based on total requests. This module will display hits, percent, 
bandwidth, [time served], [protocol] and [method].
6、Operating Systems(操作系统)
Hit totals are based on unique visitors. This module will display hits and percent. 
The expanded module shows all available versions of the parent node.
7、Browsers(浏览器和搜索引擎)
Hit totals are based on unique visitors. This module will display hits and percent. 
The expanded module shows all available versions of the parent node.
8、HTTP Status Codes(HTTP 响应代码)
The values of the numeric status code to HTTP requests. 
Hit totals are based on total requests. This module will display hits and percent.
9、Keyphrases(键盘布局)
This  module  will report keyphrases used on Google search, Google cache, 
and Google translate. Hit totals are based on total requests. This module will dis-
play hits and percent.

五、官网
http://www.goaccess.io/ 

六、这里是在debian5.0.1上编译安装goaccess
1、下载
wget http://tar.goaccess.io/goaccess-0.9.tar.gz
或axel -n 5 http://tar.goaccess.io/goaccess-0.9.tar.gz
2、解压
tar -xzvf goaccess-0.9.tar.gz
3、configure
cd goaccess-0.9/
./configure --prefix=/opt/goaccess
4、编译并安装
make && make install
5、直接使用命令
cd /opt/goaccess/bin/
cp goaccess /usr/local/sbin/
PS:我这边将goaccess安装在/opt/goaccess目录下了。

七、命令行下如何使用

goaccess -f /var/log/apache2/aaa.access.log(当然其他nginx日志也可以的)
这个时候会弹出配置窗口:

wKioL1Vb342AaguOAAHmEUnLV1o071.jpg

我这边选NCSA Combined Log Format
之后按enter就可以了
因为每次打开都会弹出这个配置窗口,可以修改以下配置文件
cat /opt/goaccess/etc/goaccess.conf |egrep -v "^#|^$"
time-format %H:%M:%S
date-format %d/%b/%Y
log-format %h %^[%d:%t %^] "%r" %s %b "%R" "%u"
再次执行的时候就不会弹出配置窗口了
也可以通过分析指定某1天的日志
grep '17/Apr/2015' aaa_access.log|goaccess

八、网页形式展示
未完待续










本文转自 xdoujiang 51CTO博客,原文链接:http://blog.51cto.com/7938217/1651862,如需转载请自行联系原作者
相关实践学习
日志服务之使用Nginx模式采集日志
本文介绍如何通过日志服务控制台创建Nginx模式的Logtail配置快速采集Nginx日志并进行多维度分析。
目录
相关文章
|
Linux PHP
easyswoole一键安装脚本,宝塔安装错误
需要注意的是,这只是几句很简单的命令,并且在文档中都有出现。只是文档有比较多的场景描述,可能导致有些新人没有细心观看到。
97 0
|
Linux PHP 虚拟化
Linux虚拟机和Window本地共享文件夹用于PHP项目调试
Linux虚拟机和Window本地共享文件夹用于PHP项目调试
144 0
Linux虚拟机和Window本地共享文件夹用于PHP项目调试
|
Shell PHP
安装Appnode面板使用php命令时bash: php :command not found问题所在及解决办法
安装Appnode面板使用php命令时bash: php :command not found问题所在及解决办法
|
弹性计算 Apache 数据库
通过命令行安装magento2
通过命令行安装magento2,可避免web安装超时。
8490 0
|
应用服务中间件 nginx
nginx打开网页报错
nginx路径配置错了,主要是斜杠问题。错误: 或者 盘符:/ 盘符: 另外,url不用加双引号正确: server { listen 8800; server_name localhost; #charset koi8-r; #access_log logs/host.
963 0
|
关系型数据库 PHP 数据库
使用命令行脚本安装 PrestaShop 1.6
从 1.5.4 版本开始,PrestaShop 同时还提供了命令行方式安装。 这是什么 这种特殊的安装程序能够安装的PrestaShop无需使用网络浏览器:简单地把zip归档的内容上传到Web服务器上,你可以通过你的命令行界面(CLI)安装的Prestashop。
1069 0
|
应用服务中间件 nginx
|
关系型数据库 MySQL Linux