找了各种工具,最终还是觉得goaccess不仅图文并茂,而且速度快,每秒8W 的日志记录解析速度,websocket10秒刷新统计数据,站在巨人肩膀上你也会看得更远…先上图: 

具体方案如下步骤: 
一、linux上安装goaccess(版本 1.1.1,一般安装在nginx所在机器上的/opt目录) 
a.先安装依赖包

yum install ncurses-devel
wget http://geolite.maxmind.com/download/geoip/api/c/GeoIP.tar.gz
tar -zxvf GeoIP.tar.gz
cd GeoIP-1.4.8/
./configure
make && make install
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

b.安装goaccess 
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

二、校对nginx的配置的日志格式(nginx.conf中log_format 使用以下自定义格式)

    log_format main '$remote_addr - $remote_user [$time_local] "$request" '

                    '$status $body_bytes_sent "$http_referer" '

                    '"$http_user_agent" "$http_x_forwarded_for" '

                    '$connection $upstream_addr '

                    '$upstream_response_time $request_time';
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

修改后重启: 
nginx -s stop 
nginx

三、生成配置文件goaccess_log_conf_nginx.conf 
vi /opt/goaccess/goaccess_log_conf_nginx.conf

time-format %T

date-format %d/%b/%Y

log_format %h - %^ [%d:%t %^] "%r" %s %b "%R" "%u" "%^" %^ %^ %^ %T
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

四、生成统计页面

手工生成当日统计页面:

goaccess -f /opt/nginx/logs/access.log -p /opt/goaccess/goaccess_log_conf_nginx.conf -o /opt/www/day-report.html
  • 1

生成实时统计页面:

nohup goaccess -f /opt/nginx/logs/access.log -p /opt/goaccess/goaccess_log_conf_nginx.conf -o /opt/www/real-time-yong-report.html --real-time-html --ws-url=report.xxx.com &
  • 1
检查是否存在进程:  ps -ef|grep goaccess
  • 1
  • 2

五、开通对外访问地址 
a.安装新的tomcat(假设在/opt/report-tomcat目录) 端口:7891 修改conf/server.xml中的端口,并增加访问目录:

<Host name="localhost"  appBase="webapps"
unpackWARs="true" autoDeploy="false"> <Context path="/" docBase="/opt/www" />
</Host> 然后增加权限与角色( conf/tomcat-users.xml) : <role rolename="report"/>
<user username="report" password="reportxxx" roles="report"/> 最后在webapps/ROOT/WEB-INFO/web.xml的web-app中增加: <security-constraint>
<web-resource-collection>
<web-resource-name>
Restricted Area
</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection> <auth-constraint>
<role-name>report</role-name>
</auth-constraint>
</security-constraint> <login-config>
<auth-method>BASIC</auth-method>
<realm-name>Authenticate yourself</realm-name>
</login-config> b.确认统计端口:7890、7891对外开放 c.访问页面是否ok
手工生成当日统计页面:http://report.xxx.com:7891/day-report.html
实时统计页面: http://report.xxx.com:7891/real-time-yong-report.html
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40

附: 
参考链接: 
各种日志格式转换工具:https://github.com/stockrt/nginx2goaccess 
goaccess官网:https://goaccess.io

 以上是我直接复制的,感谢
https://blog.csdn.net/yown/article/details/56027112

goaccess的更多相关文章

  1. goaccess的安装和使用

    一.简介1.goaccess用于分析apache和nginx日志的强大工具 2.官网:https://goaccess.io 二.安装1.下载goaccess的安装包wget http://tar.g ...

  2. nginx日志分析利器GoAccess

    面试的时候一定会被面到的问题是:给出web服务器的访问日志,请写一个脚本来统计访问前10的IP有哪些?访问前10的请求有哪些?当你领略过goaccess之后,你就明白,这些问题,除了考验你的脚本背诵记 ...

  3. 网站日志实时分析工具GoAccess使用

    网站日志实时分析工具GoAccess使用 系统环境CentOS release 5.5 (Final) GoAccess是一款开源的网站日志实时分析工具. GoAccess 的工作方式就是读取和解析 ...

  4. GoAccess日志分析工具使用文档

    ----Sevck 2016/3/4 17:24:13 #1软件说明: GoAccess是一款开源.实时,运行在命令行终端下的web日志分析工具.该工具提供快速.多样的HTTP状态统计,可以令管理员不 ...

  5. jboss7访问日志功能及使用goaccess工具分析

    网络上虽然很多文章分别讲到jboss7的访问日志如何配置,goaccess工具怎么分析nginx/tomcat等日志.但将两者放在一起即“通过goaccess分析jboss访问日志”的倒是没搜索到. ...

  6. 用GOACCESS分析NGINX日志

    参考URL: http://4b3r.com/goaccess-analyze-nginx-access-log/64/ http://jesuspan.sinaapp.com/crontab%E6% ...

  7. Goaccess解析nginx日志备忘

    参考 http://nginx.org/en/docs/http/ngx_http_log_module.html?&_ga=1.92028562.949762386.1481787781#l ...

  8. nginx 日志分析工具goaccess

    参考:https://www.goaccess.io/download 安装 $ wget http://tar.goaccess.io/goaccess-1.1.1.tar.gz $ tar -xz ...

  9. 安装部署 Goaccess

    CentOS 7安装 Goaccess 安装依赖 # yum install ncurses-devel geoip-devel libmaxminddb-devel tokyocabinet-dev ...

  10. 日志分析工具之goAccess

    在此推荐一款分析日志的工具,方便我们日常对于网站的访问状况有一个较为清晰的了解  一.安装 官网: https://goaccess.io/download 源码安装: 1. wget http:// ...

随机推荐

  1. PAT 乙级 1091 N-自守数 (15 分)

    1091 N-自守数 (15 分) 如果某个数 K 的平方乘以 N 以后,结果的末尾几位数等于 K,那么就称这个数为“N-自守数”.例如 3×92​2​​=25392,而 25392 的末尾两位正好是 ...

  2. Java中运行时异常和非运行时异常什么鬼?

    Java中的异常分类 RuntimeException(也称unchecked exceptions,运行时异常) 就是我们在开发中测试功能时程序终止,控制台出现的异常.(一般来说,出现运行时异常基本 ...

  3. base64 压缩上传上传图片

    @{ ViewBag.Title = "dddddddd"; Layout = "~/Areas/Wap/Views/Shared/_Head.cshtml"; ...

  4. C语言数据结构基础学习笔记——栈和队列

    之前我们学过了普通的线性表,接下来我们来了解一下两种特殊的线性表——栈和队列. 栈是只允许在一端进行插入或删除的线性表. 栈的顺序存储结构也叫作顺序栈,对于栈顶指针top,当栈为空栈时,top=-1: ...

  5. 小程序开发------mpvue开发时间轴

    亲们支持我的新博客哦==>地址(以后更新会尽量在新博客更新,欢迎大家访问加入我的后宫w) ) 效果展示: 技术栈:mpvue demo==> 代码:

  6. 一步步实现:springbean的生命周期测试代码

    转载. https://blog.csdn.net/baidu_37107022/article/details/76552052 1. 创建实体SpringBean public class Spr ...

  7. JS stringObject.Match()

    JavaScript match() 方法 JavaScript String 对象 定义和用法 match() 方法可在字符串内检索指定的值,或找到一个或多个正则表达式的匹配. 该方法类似 inde ...

  8. mysql修改用户密码的方法及命令

    方法1: 用SET PASSWORD命令 首先登录MySQL. 格式:mysql> set password for 用户名@localhost = password('新密码'); 例子:my ...

  9. 5.HTML+CSS制作一颗流星

    效果地址:https://codepen.io/flyingliao/pen/pBzKbZ HTML code: <div class="sky"> <span& ...

  10. iReport-5.6.0 新建文件为什么是灰色的?新建项目没有选择项?

    从网上下了绿色版和安装版都出现这个问题. 解决:发现原来是有些插件没有激活,进入手动激活就ok了 -->工具-->插件-->已安装 ,选择未激活的手动激活. 激活成功后如下图(和我同 ...