最近因为项目要求,需要监控一下网络请求访问以及可视化的解决,看了很多的工具发现GoAccess能满足自己的需求又支持可视化,很方便。
官网下载地址 https://goaccess.io/download
下载页面有各种安装的方式,以下简单的举例说明
Fedora
# yum install goaccess
Arch Linux
# pacman -S goaccess
Gentoo
# emerge net-analyzer/goaccess
OS X / Homebrew
# brew install goaccess 安装成功后
# 使用goaccess监控 goaccess /var/log/nginx/access.log -o /usr/local/nginx/html/report.html --real-time-html --time-format='%H:%M:%S' --date-format='%d-%b-Y' --log-format=COMBINED
#中文化 goaccess配置好之后,将生成的xxx.html文件当做nginx或者其他web的访问页面,就可以直接在浏览器中查看到日志的分析情况,比如请求的文件,访客的主机名和ip 地址,状态码等信息,但是是英文显示的,对一些非技术人员来说,可能看起来不那么只管,所以可以将其配置为中文显示,步骤如下: 1、修改goaccess所在服务器的系统语言为中文 #cat /etc/sysconfig/i18n LANG="zh_CN.UTF-8" 为了让其立刻生效,在shell界面执行
LANG="zh_CN.UTF-8" goaccess /var/log/nginx/access.log -o /usr/local/nginx/html/report.html --real-time-html --time-format='%H:%M:%S' --date-format='%d-%b-Y' --log-format=COMBINED
成功展示