您好,登录后才能下订单哦!
1、GoAccess简介:
GoAccess是一款开源的且具有交互视图界面的实时Web日志分析工具,其核心思想是实时快速分析和查看Web服务器的统计信息,GoAccess支持生成完整的实时HTML报告以及JSON和CSV格式的报告。
2、yum方式安装GoAccess所需软件包:
# yum install GeoIP-devel ncurses ncurses-devel wget epel-release
3、编译安装GoAccess:
# wget https://tar.goaccess.io/goaccess-1.3.tar.gz
# tar -xf goaccess-1.3.tar.gz -C /usr/src
# cd /usr/src/goaccess-1.3
# ./configure --prefix=/usr/local/goaccess --enable-utf8 --enable-geoip
# make && make install
4、配置环境变量:
# vim /etc/profile.d/goaccess.sh
export PATH=/usr/local/goaccess/bin:$PATH
# . /etc/profile.d/goaccess.sh
# goaccess -V
5、修改nginx.conf配置文件:
# vim /etc/nginx/nginx.conf,确认如下配置默认已启用:
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
6、修改goaccess.conf配置文件:
# cd /usr/local/goaccess/etc/goaccess/
# cp goaccess.conf{,.bak}
# vim goaccess.conf
修改前 | 修改后 |
#time-format %H:%M:%S | time-format %H:%M:%S |
#date-format %d/%b/%Y | date-format %d/%b/%Y |
#log-format %h %^[%d:%t %^] "%r" %s %b "%R" "%u" | log-format %h %^[%d:%t %^] "%r" %s %b "%R" "%u" |
#log-format COMBINED | log-format COMBINED |
#addr 0.0.0.0 | addr 192.168.0.121 |
#daemonize false | daemonize true |
#port 7890 | port 7890 |
#pid-file /var/run/goaccess.pid | pid-file /var/run/goaccess.pid |
#real-time-html true | real-time-html true |
#ws-url goaccess.io | ws-url 192.168.0.121 |
#log-file /var/log/apache2/access.log | log-file /var/log/nginx/access.log |
#config-file <filename> | config-file /usr/local/goaccess/etc/goaccess/goaccess.conf |
# output /path/file.html | output /usr/share/nginx/html/goaccess.html |
7、控制台运行GoAccess:
# goaccess /var/log/nginx/access.log
8、后台实时生成数据到GoAccess界面,并将分析结果保存为HTML:
# goaccess -p /usr/local/goaccess/etc/goaccess/goaccess.conf
或# goaccess /var/log/nginx/access.log --time-format='%H:%M:%S' --date-format='%d/%b/%Y' --log-format=COMBINED -o /usr/share/nginx/html/goaccess.html --addr=192.168.0.121 --real-time-html --daemonize
# ps -ef | grep goaccess
# ss -tunlp | grep 7890
备注:如果需要输出实时HTML,需要打开防火墙7890端口
9、浏览器访问http://192.168.0.121/goaccess.html
10、使用ab命令进行压测,模拟访问,观察页面数值是否实时变化:
# yum -y install httpd-tools
# ab -n 500000 -c 20 http://192.168.0.121/
备注:可从https://goaccess.io/获取帮助信息
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。