Goaccess Automatic partition Nginx log

Source: Internet
Author: User
Tags geoip

Goaccess is an open-source website log real-time analysis tool. The way goaccess works is easy to understand, reading and parsing apache/nginx/lighttpd access log files, and then displaying the statistics in a more friendly way. Statistics include: Access profile, dynamic page requests, static page requests (slices, style sheets, scripts, etc.), visitor rankings, guest use of the operating system, browser used by visitors, routing domain names, 404 errors, search crawlers, search keywords and so on.

Installing components
Yum-y Install glib2 glib2-devel ncurses ncurses-devel GeoIP geoip-devel
Download Source Package Installation
wget http://tar.goaccess.io/goaccess-0.8.5.tar.gz
Tar zxvf goaccess-0.8.5.tar.gz-c/usr/src/
cd/usr/src/goaccess-0.8.5/
./configure--prefix=/usr/local/goaccess
Make && make install

Download file
cd/usr/local/goaccess/
Wget-o goaccessrc https://raw.githubusercontent.com/allinurl/goaccess/master/config/goaccess.conf-- No-check-certificate
Edit File
Vim GOACCESSRC
Remove comments from the following 22, 33 lines, adding 235 lines of comments

Date-format%d/%b/%y
Log-format%h%^[%d:%t%^] "%r"%s%b "%r" "%u"
235 #ignore-panel Keyphrases

Create a Web page directory
mkdir html
Generate a Web page report
/usr/local/goaccess/bin/goaccess-f/usr/local/nginx/logs/access.log-d-a-p/usr/local/goaccess/goaccessrc > usr /local/goaccess/html/access.html

Nginx Release Goaccess Web page

cd/usr/local/nginx/conf/vhosts/
VI goaccess.conf

server {
Listen 80;
server_name goaccess.xx.com;
AutoIndex on;
Location/{
root/usr/local/goaccess/html;
}
}

Reload
/usr/local/nginx/sbin/nginx-s Reload

Visit Web pages
Http://goaccess.xx.com/access.html
Wkiol1vk-4ib_zlqaaji0skvsms176.jpg

The following is a description of Nginx log cutting and automatic generation of Web reports and Chinese.
VI nginx_cut.sh

#!/bin/bash

############ #日志切割 ###########################
Time= ' date-d today +%y%m%d%h%m '
/usr/local/nginx/sbin/nginx-s stop
Cd/usr/local/nginx/logs
MV Access.log Access_$time.log
MV Error.log Error_$time.log
/usr/local/nginx/sbin/nginx
#删除超过7天的日志文件
Find/usr/local/nginx/logs-ctime 3-type f-name "*.log"-exec rm {} \;

#自动生成网页报告
/usr/local/goaccess/bin/goaccess-f access_$time.log-d-a-p/usr/local/goaccess/goaccessrc >/usr/local/goaccess/ Html/access_$time.html

#自动汉化网页报告文件
echo access_$time.html >/tmp/time.log
/manage/hanhua.sh

#删除超过7天的报告文件
Find/usr/local/goaccess/html-ctime 7-type f-name "*.html"-exec rm {} \;

Edit Chinese script, English translation reference Baidu translation, may not be too accurate.
vi/manage/hanhua.sh

#/bin/bash

File= ' Cat/tmp/time.log '

Cd/usr/local/goaccess/html
Sed-i ' s/overall/overall/g ' $file
Sed-i ' s/unique visitors/Independent visitor/g ' $file
Sed-i ' s/requested files/requested file/g ' $file
Sed-i ' s/requested static file/g ' $file
Sed-i ' S/not found urls/not found URL/g ' $file
Sed-i ' s/hosts/host/g ' $file
Sed-i ' s/operating systems/operating system/g ' $file
Sed-i ' s/browsers/browser/g ' $file
Sed-i ' s/referrers urls/reverse link url/g ' $file
Sed-i ' s/referring sites/reference website/g ' $file
Sed-i ' s/keyphrases/keyword/g ' $file
Sed-i ' s/status codes/status code/g ' $file
Sed-i ' s/generated by/generated/g ' $file
Sed-i ' s/dashboard/instrument panel/g ' $file
Sed-i ' s/analyzed requests/analysis request/g ' $file
Sed-i ' s/total requests/Total request/g ' $file
Sed-i ' s/failed requests/request failed/g ' $file
Sed-i ' s/generation time/generation time/g ' $file
Sed-i ' s/unique visitors/Independent visitor/g ' $file
Sed-i ' s/unique files/unique file/g ' $file
Sed-i ' s/excl. IP hits/except IP click/g ' $file
Sed-i ' s/referrers/reverse link/g ' $file
Sed-i ' S/unique 404/Unique 404/g ' $file
Sed-i ' s/static files/static file/g ' $file
Sed-i ' s/log size/log size/g ' $file
Sed-i ' s/bandwidth/bandwidth/g ' $file
Sed-i ' S/per day/every day/g ' $file
Sed-i ' s/including spiders/including spider/g ' $file
Sed-i ' s/hits Having the same ip/has the same IP click/g ' $file
Sed-i ' s/date and Agent is a unique visit/date and proxy is a special access/g ' $file
Sed-i ' s/top requested files sorted by hits/requested file click on top of/g ' $file
Sed-i ' s/time served/time delivery/g ' $file
Sed-i ' s/protocol/protocol/g ' $file
Sed-i ' s/method/method/g ' $file
Sed-i ' s/hits/click/g ' $file
Sed-i ' s/protocol/protocol/g ' $file
Sed-i ' s/method/method/g ' $file
Sed-i ' s/top 404 Not Found URLs sorted by hits/top 404 No URLs sorted by click-through rate/g ' $file
Sed-i ' s/top/ago/g ' $file
Sed-i ' s/sorted by hits/ctr/g ' $file
Sed-i ' s/bandwidth/bandwidth/g ' $file
Sed-i ' s/hostname/host name/g ' $file
Sed-i ' s/sorted by unique visitors/sort/g ' $file
Sed-i ' s/requested/requires/g ' $file
Sed-i ' s/status codes/status code/g ' $file
Sed-i ' s/code/code/g ' $file
Sed-i ' s/visitors/visitor/g ' $file
Sed-i ' s/name/name/g ' $file
Sed-i ' S/not Found urls/not found URL/g ' $file
Sed-i ' s/or Service not known/or service does not know/g ' $file
Sed-i ' s/pages/page/g ' $file
Sed-i ' s/referring sites/reference website/g ' $file

Visit Web pages
http://goaccess.xx.com/
Wkiom1vk-ltjiw3qaacuvymofec868.jpg
Click on the webpage file
After the Chinese page effect is as follows:
Wkiol1vk--ucjqyaaahdhwfvtbu010.jpg
This article is from the "Falling Star" blog, make sure to keep this source http://xiao987334176.blog.51cto.com/2202382/1643811

Goaccess Automatic partition Nginx log

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.