日誌格式:html
127.0.0.1 127.0.0.1 127.0.0.1 - "01/Aug/2016:11:10:10 +0800" 200 64513 3.045 "-" "GET /media01/9b890f3678b54c0da14a4749aa4073e6_dat-full.dat HTTP/1.1" "python-requests/2.2.1 CPython/2.7.6 Linux/3.16.0-30-generic" 30860
goaccess配置格式:python
%d date field matching the date_format variable.【日期】 %h host (the client IP address, either IPv4 or IPv6)【請求客戶端ip】 %r The request line from the client.【請求】 %s The status code that the server sends back to the client.【響應碼】 %b The size of the object returned to the client.【返回數據大小】 %R The "Referer" HTTP request header.【頭部信息,referer】 %u The User-Agent HTTP request header.【用戶agent】 %D The time taken to serve the request, in microseconds.【響應時間,ms】 %T The time taken to serve the request, in seconds. Note: %D will take priority over %T if both are used. 【響應時間,秒爲單位】 %^ Ignore this field.【忽略】
生成/root/.goaccessrc文件內容爲:nginx
color_scheme 0 date_format %d/%b/%Y log_format %^ %^ %h - "%d:%^" %s %b %T "-" "%r" "%u" %^
定時腳本:bash
#!/bin/bash dateformat=`date +"%Y%m%d"` logfile="/usr/local/nginx/logs/access.log-$dateformat" lochost=`hostname` anafile="/home/$lochost/nginx_analysis/access-analysis.html" emlfile="/home/$lochost/nginx_analysis/nginx_mail.py" if [[ -f $logfile ]] then goaccess -f $logfile -a > $anafile python $emlfile fi