linux安装goAccess日志分析工具
linux安装goAccess日志分析工具
Alex安装goAccess日志分析工具
1 | $ wget http://tar.goaccess.io/goaccess-1.2.tar.gz |
- 如果出现错误
configure: error: *** Missing development files for the GeoIP library
- 解决办法
1
2
3yum install GeoIP-devel
yum install php-pear
yum install php-pecl-geoip - 再重新配置 -> 编译 ->安装
- 测试日志分析
1
goaccess -f time_access.log -a > report.html
- 错误提示
1
2
3Fatal error has occurred
Error occured at: src/parser.c - verify_formats - 1691
No time format was found on your conf file. - 添加配置文件
1
2
3
4vi ~/.goaccessrc
time-format %T
date-format %d/%b/%Y
log-format %h %^[%d:%t %^] "%r" %s %b "%R" "%u" - 添加参数-p制定时间格式化配置文件
1
goaccess -f time_access.log -p ~/.goaccessrc -a > report.html
- 配置nginx文件自动分割脚本
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#!/bin/bash
# Program:
# Auto cut nginx log script.
# 2017/6/30 Alex
# nginx日志路径 /data/log/nginx/log
LOGS_PATH=/data/log/nginx
TODAY=$(date -d 'today' +%Y-%m-%d)
#echo $TODAY
# 移动日志并改名
mv ${LOGS_PATH}/edu_online.com.access.log ${LOGS_PATH}/log/access_edu_online_${TODAY}.log
mv ${LOGS_PATH}/edu_online.com.error.log ${LOGS_PATH}/log/error_edu_online_${TODAY}.log
# 向nginx主进程发送重新打开日志文件的信号
#kill -USR1 $(cat /var/run/nginx.pid)
nginx -s reload
nginx日志格式设置
1 | log_format main '$remote_addr - $remote_user [$time_local] "$request" ' |
- 对应时间格式设置
1
2
3
4
5time-format %T
date-format %d/%b/%Y
log_format %h - %^ [%d:%t %^] "%r" %s %b "%R" "%u" "%^" %^ %^ %^ %T