1.GoAccess基本概述

GoAccess是一个基于终端的快速日志分析器。其核心思想是实时快速分析和查看Web服务器统计信息。

1.安装简单;

2.操作容易;

3.界面酷炫;

2.GoAccess安装方式

安装分为yum安装与源码安装,大家可以自行选择,我这里选择使用源码的方式安装

2.1.安装goaccess

[root@xly ~]# wget https://tar.goaccess.io/goaccess-1.3.tar.gz
[root@xly ~]# tar -xzvf goaccess-1.3.tar.gz
[root@xly ~]# cd goaccess-1.3/
[root@xly ~]# yum install -y GeoIP-deve ncurses-devel
[root@xly goaccess-1.3]# ./configure --enable-utf8 --enable-geoip=legacy
[root@xly goaccess-1.3]# make && make install

2.2.goaccess基本使用

指定分析日志
[root@xly ~]# goaccess -f /var/log/nginx/access.log 按空格选择 NCSA Combined Log Format
注意: 如果是Nginx默认的日志格式无需调整选中回车即可。

2.3.等待一会时间后,会展示分析的结果

3.GoAccess使用方式

3.1.我们更希望能将此页面保存为HTML,然后通过浏览器访问,那么我们则需要配置日志格式

#搜索并修改如下配置。
[root@xly ~]# mkdir -p /usr/local/etc/goaccess/
[root@xly ~]# touch /usr/local/etc/goaccess/goaccess.conf
[root@xly ~]# vim /usr/local/etc/goaccess/goaccess.conf
time-format %H:%M:%S
date-format %d/%b/%Y
#NCSA Combined Log Format
log-format %h %^[%d:%t %^] "%r" %s %b "%R" "%u"

3.2.通过命令指定配置,将生成的信息保存为html

#1.测试是否能通过终端直接展示
[root@xly ~]# goaccess -f /var/log/nginx/access.log -p /usr/local/etc/goaccess/goaccess.conf #2.将分析结果保存为hTML
[root@xly ~]# goaccess /var/log/nginx/access.log -o /code/log/index.html -p /usr/local/etc/goaccess/goaccess.conf Parsing... [323,899] [53,983/s]

3.3.添加定时任务,每隔30分钟执行一次

[root@xly ~]# crontab -e
#每隔30分钟生成一次html文件
30 * * * * /usr/local/bin/goaccess /var/log/nginx/access.log -o /code/log/index.html -p /usr/local/etc/goaccess/goaccess.conf

3.4.配置一个Nginx虚拟主机,将root指向/code/log,这样可以通过域名去访问html页面

1.虚拟主机,在原有的配置加一个location

	location /log {
root /code;
index index.html;
}

最新文章

  1. centos6.6 安装cacti监控服务器
  2. typedef 函数指针 数组 std::function
  3. ListView到顶部不可再拉
  4. JS this指向问题
  5. 在Linux操作系统下备份恢复技术的应用 转自https://yq.aliyun.com/articles/50205?spm=5176.100239.blogcont24250.9.CfBYE9
  6. 安装dos2unix
  7. MySQL数据故障时备份与恢复
  8. cocos进阶教程(2)多分辨率支持策略和原理
  9. Side by Side Assembly介绍--manifest文件的使用
  10. Android 主题动态切换框架:Prism
  11. html转图片
  12. 开发设计模式(四) 代理模式(Proxy Pattern)
  13. BZOJ1634: [Usaco2007 Jan]Protecting the Flowers 护花
  14. oracle时间戳转换
  15. 虚拟机下opensips 启动
  16. Redis参数配置和运维说明
  17. Oracle高水位2
  18. 【原创】python实现清理本地缓存垃圾
  19. JAVA读取和写入properties文件
  20. Django知识总结(二)

热门文章

  1. maven 打包异常
  2. 综合开源框架之RxJava/RxAndroid
  3. 代码实现:从键盘输入接收一个文件夹路径,打印出该文件夹下所有的.java文件名
  4. 读取web工程中.properties资源文件的模板代码
  5. Python--偏函数(Partial)
  6. maven的基本使用
  7. java:redis(redis安装配置,redis的伪集群配置)
  8. danbooru 图片下载工具。
  9. 【POJ - 3279】Fliptile(经典翻转问题)
  10. servlet学习之servletAPI编程常用的接口和类