安装goAccess日志分析工具
$ wget http://tar.goaccess.io/goaccess-1.2.tar.gz
$ tar -xzvf goaccess-1.2.tar.gz
$ cd goaccess-1.2/
$ ./configure --enable-utf8 --enable-geoip=legacy
$ make
# make install
- 如果出现错误
configure: error: *** Missing development files for the GeoIP library
- 解决办法
yum install GeoIP-devel
yum install php-pear
yum install php-pecl-geoip
goaccess -f time_access.log -a > report.html
Fatal error has occurred
Error occured at: src/parser.c - verify_formats - 1691
No time format was found on your conf file.
vi ~/.goaccessrc
time-format %T
date-format %d/%b/%Y
log-format %h %^[%d:%t %^] "%r" %s %b "%R" "%u"
goaccess -f time_access.log -p ~/.goaccessrc -a > report.html
#!/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日志格式设置
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';
time-format %T
date-format %d/%b/%Y
log_format %h - %^ [%d:%t %^] "%r" %s %b "%R" "%u" "%^" %^ %^ %^ %T