温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

goaccess如何安装和使用

发布时间:2021-11-16 10:48:59 来源:亿速云 阅读:268 作者:小新 栏目:服务器

这篇文章主要为大家展示了“goaccess如何安装和使用”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“goaccess如何安装和使用”这篇文章吧。

一、Debian下安装goaccess
cat /etc/debian_version 
6.0.10
apt-cache search goaccess
goaccess - log analyzer and interactive viewer for the Apache Webserver
apt-get -y install goaccess

二、Centos下安装goaccess
cat /etc/redhat-release 
CentOS release 6.6 (Final)
yum list|grep goaccess
goaccess.x86_64                            0.8.5-1.el6                   epel
yum -y install goaccess
没有epel源的话需要安装
rpm -Uvh http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm

三、参数说明

-b Enable total bandwidth consumption. To achieve faster parsing, 
do not enable this flag.  This has been disabled by default.(流量统计)
-f input-file path to input log filename(日志文件名)
-s Enable/report HTTP status codes. To avoid overhead while parsing, 
this has been disabled by default.(HTTP响应代码统计)
-e Exclude an IP from being count it under the HOST module. 
This has been disabled by default.(指定IP地址统计,默认禁用)指定还是排除?
-c Prompt log/date configuration window.(配置)
-a Enable a List of User-Agents by host.(用户代理统计)

四、功能说明
1、General Statistics(统计概况,流量消耗)
Number  of valid requests, number of invalid requests, time to analyze the data, 
unique visitors, unique requested files, unique static files (css, ico, jpg,
js, swf, gif, png) unique HTTP referrers (URLs), unique 404s (not found), 
size of the parsed log file, bandwidth consumption.
2、Unique visitors(访客排名)
HTTP requests having the same IP, same date and same agent will be considered a 
unique visit. This includes crawlers.
3、Requested files(动态Web请求)
Hit totals are based on total requests. This module will display hits, percent, 
bandwidth [time served], [protocol] and [method].
4、Requested static files(静态web请求,如图片、样式表、脚本等)
Hit totals are based on total requests. Includes files such as: jpg, css, swf, js, 
gif, png etc. 
This module will display hits,percent,bandwidth,[time served],[protocol] and [method].
5、404 or Not Found(404 错误)
Hit totals are based on total requests. This module will display hits, percent, 
bandwidth, [time served], [protocol] and [method].
6、Operating Systems(操作系统)
Hit totals are based on unique visitors. This module will display hits and percent. 
The expanded module shows all available versions of the parent node.
7、Browsers(浏览器和搜索引擎)
Hit totals are based on unique visitors. This module will display hits and percent. 
The expanded module shows all available versions of the parent node.
8、HTTP Status Codes(HTTP 响应代码)
The values of the numeric status code to HTTP requests. 
Hit totals are based on total requests. This module will display hits and percent.
9、Keyphrases(键盘布局)
This  module  will report keyphrases used on Google search, Google cache, 
and Google translate. Hit totals are based on total requests. This module will dis-
play hits and percent.

  • -f – 日志文件名

  • -b – 开启流量统计,如果希望加快分析速度不建议使用该参数

  • -s – 开启HTTP响应代码统计

  • -a – 开启用户代理统计

  • -e – 开启指定IP地址统计,默认禁用

  • -p -指定goacces用户配置文件路径

  • F1 帮助菜单

  • F5 刷新

  • q 退出当前口窗、菜单、或是当前查看的选项

  • o 打开当前的选项、菜单

  • c 改变窗口配色(目前只有两种 默认和绿色)

  • SHIFT + TAB 从当前选定模块向后切换

  • RIGHT 打开当前选中模块,查看详细信息

  • s 通过日期排序,只会在访问请求模块起作用

  • S 通过点击次数排序,只会在访问请求模块起作用

  • / 查看详细信息的窗口进行搜索

  • n 通过/进行查找后,查找下个匹配的内容的位置,如果没有则在窗口底部显示“search hit BOTTOM”

  • t 在查看详细信息窗口,移动指针到最顶部

  • b 在查看详细信息窗口,移动指针到最底部

apache - what is? - how in goaccess

%v - vhost - %^ ignore it

%h - host - %h

%l - hyphen - %^ ignore it

%u - user - %^ ignore it

%t - timestamp - [%d:t% %^] ignore the zone from apache log

%r - request - %r

%s - status - %s

%b - size - %b

%{referer}i - request header - %R

%{UAgent}i - user agent - %u

%d date field matching the date_format variable.

%h host (the client IP address, either IPv4 or IPv6) IT网,http://www.it.net.cn

%r The request line from the client. This requires specific delimiters around the request (as single quotes, double quotes, or anything else) to be parsable. If not, we
have to use a combination of special format specifiers as %m %U %H.

%m The request method.

%U The URL path requested (including any query string).

%H The request protocol.

%s The status code that the server sends back to the client. IT网,http://www.it.net.cn

%b The size of the object returned to the client.

%R The “Referrer” HTTP request header.

%u The user-agent HTTP request header. Linux学习,http:// linux.it.net.cn

%D The time taken to serve the request, in microseconds.

%T The time taken to serve the request, in seconds or milliseconds. Note: %D will take priority over %T if both are used.

%^ Ignore this field. Lin

date_format  See http://linux.die.net/man/3/strftime
开始日志分析并导出为html文件:

1

[root@Rootop ~]# goaccess -f /home/wwwlogs/www.rootop.org.log --log-format='%h %^[%d:%^] "%r" %s %b "%R" "%u"' --date-format='%d/%b/%Y' -d -a > test.html

或者
[root@Rootop ~]# goaccess -f /home/wwwlogs/www.rootop.org.log -d -a -p ~/.goaccessrc > test2.html

使用bash/sed/awk手动查找Nginx日志

#按日期查找时间段 sed -n "/14//Jul//2015:00:00:00/,/15//Jul//2015:15:00:00/"p access.log > time_access.log
#查找504错误的页面和数量 awk '($9 ~ /504/)' time_access.log | awk '{print $7}' | sort | uniq -c | sort -rn > 504.log
#查找访问最多的20个IP及访问次数 awk '{print $1}' time_access.log | sort | uniq -c | sort -n -k 1 -r | head -n 20 > top.log

以上是“goaccess如何安装和使用”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI