Linux运维最佳实践pdf下载
goaccess的一些使用笔记
#直接打开
goaccess -f access.log
#添加配置文件
vi ~/.goaccessrc
vi ~/.goaccessrc
time-format %T
date-format %d/%b/%Y
log-format %h %^[%d:%t %^] "%r" %s %b "%R" "%u"
date-format %d/%b/%Y
log-format %h %^[%d:%t %^] "%r" %s %b "%R" "%u"
##常用例子
goaccess -f /home/wwwlogs/logs/access.20160425.log -p ~/.goaccessrc -a > report.html
#直接打开
goaccess -f access.log
#选择日志格式
NCSA Combined Log Format
NCSA Combined Log Format
#剩下的操作都蛮简单的,参考扩展阅读和官方文档吧
#导出HTML报告会遇到的问题
goaccess -f time_access.log -a > report.html
goaccess -f time_access.log -a > report.html
GoAccess - version 0.9.2 - Jul 15 2015 16:23:20
Config file: /usr/local/etc/goaccess.conf
Config file: /usr/local/etc/goaccess.conf
Fatal error has occurred
Error occured at: src/parser.c - verify_formats - 1691
No time format was found on your conf file.
Error occured at: src/parser.c - verify_formats - 1691
No time format was found on your conf file.
#重新指定配置文件后执行
goaccess -f time_access.log -p ~/.goaccessrc -a > report.html
goaccess -f /home/wwwlogs/logs/access.20160425.log -p ~/.goaccessrc -a > report.html
goaccess -f time_access.log -p ~/.goaccessrc -a > report.html
goaccess -f /home/wwwlogs/logs/access.20160425.log -p ~/.goaccessrc -a > report.html
使用bash/sed/awk手动查找Nginx日志
更多技巧可以参考扩展阅读,Python的处理效率或者更优
更多技巧可以参考扩展阅读,Python的处理效率或者更优
#按日期查找时间段
sed -n "/14\/Jul\/2015:00:00:00/,/15\/Jul\/2015:15:00:00/"p access.log > time_access.log
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
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
awk '{print $1}' time_access.log | sort | uniq -c | sort -n -k 1 -r | head -n 20 > top.log
转载请注明:谷谷点程序 » linux下goaccess常用使用方法