goaccess配置nginx日志解析

 日志格式:

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配置格式:


       %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文件内容为:

color_scheme 0
date_format %d/%b/%Y
log_format %^ %^ %h - "%d:%^" %s %b %T "-" "%r" "%u" %^

定时脚本:

#!/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

 

转载于:https://my.oschina.net/u/259976/blog/724801

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值