nginx 日志分析工具goaccess

意外概述

总的来说, 有时候需要手动加前缀/usr/local/bin/goaccess才能运行程序;

除非config的时候添加了--prefix=/usr/bin之类的.

不能单独设置log-format, 必须一并设置时间格式.

前置

sudo apt-get install libncursesw5-dev

~/.goaccessrc

date-format %d/%b/%Y
time-format %H:%M:%S
log-format %h %^[%d:%t %^] "%r" %s %b "%R" "%u" %T

符号含义见SPECIFIERS

https://goaccess.io/man

安装

$ wget http://tar.goaccess.io/goaccess-1.1.1.tar.gz
$ tar -xzvf goaccess-1.1.1.tar.gz
$ cd goaccess-1.1.1/
$ ./configure --enable-geoip --enable-utf8
$ make
# make install

一键解析文本文件

cat `find /var/log/nginx -regextype posix-egrep -regex ".*/access\.log\.[0-9]{1,2}"` | goaccess -a -o ~/static/report3.html --log-format=COMBINED

一键解析gz文件

zcat access*.gz | goaccess -a -o ~/report.html --log-format=COMBINED

or

zcat logs/access*.gz | /usr/local/bin/goaccess -a -o dist/report.html --log-format=COMBINED

echo "deb http://deb.goaccess.io/ $(lsb_release -cs) main" | sudo tee -a /etc/apt/sources.list.d/goaccess.list

wget -O - https://deb.goaccess.io/gnugpg.key | sudo apt-key add -

apt-get update

apt-get install goaccess

To output to a terminal and generate an interactive report:

goaccess -f access.log

To generate an HTML report:

goaccess -f access.log -a -o report.html

To generate a JSON report:

goaccess -f access.log -a -d -o report.json

To generate a CSV file:

goaccess -f access.log --no-csv-summary -o report.csv

goaccess -f all -a -o report.html --log-format=COMBINED

上一篇:动态加载Layout 与 论Activity、 Window、View的关系


下一篇:IIS在W7下使用