继GoAccess 的示例,它通过以下方式安装在 Debian 上apt-get
:
sudo apt-get install goaccess
日志文件归 www-dataadm
组所有:
$ admin@mycomputer:~# ls -l /var/log/nginx/
ls: cannot open directory /var/log/nginx/: Permission denied
$ sudo -i
root@mycomputer:~# ls -l /var/log/nginx/
-rw-r----- 1 www-data adm 9780 Aug 1 22:11 access.log
# etc...
作为admin
用户,我可以使用 sudo 成功运行基本的 GoAccess 命令:
$ sudo goaccess -f /var/log/nginx/access.log
凉爽的!
General Dashboard - Overall Analyzed Requests [Active Module 0]
Total Requests 51 Unique Visitors 26 Referrers 0 Log Size 9.55 KiB
Failed Requests 0 Unique Files 18 Unique 404 0 Bandwidth 0.0 B
Generation Time 0 Static Files 0 Log File /var/log/nginx/access.log
Unique visitors per day - Including spiders Total: 1/1
Hits having the same IP, date and agent are a unique visit
26 100.00% 0.0 B 01/Aug/2016 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Requested files (Pages-URL) Total: 18/18
Top requested files - hits, percent, [bandwidth, time served]
24 47.06% 0.0 B /
4 7.84% 0.0 B http://www.baidu.com/s?wd=5118
2 3.92% 0.0 B /contact/
[F1]Help [O]pen detail view 0 - Mon Aug 1 23:38:47 2016 [Q]uit GoAccess 0.6
如果没有 sudo (或者如果我以 root 身份运行它,则找不到日志文件:
$ goaccess -f /var/log/nginx/access.log
GoAccess - version 0.6 - Oct 21 2013 23:06:19
An error has occurred
Error occured at: parser.c - parse_log - 798
Message: Error while opening the log file. Make sure it exists.
但是当我以 sudo 身份运行时,选项/标志下列的无法识别日志文件名:
$ sudo goaccess -f /var/log/nginx/access.log -o report.html --real-time-html
Unknown option `-o'.
$ sudo goaccess -f /var/log/nginx/access.log --no-csv-summary -o report.csv
Unknown option `--'.
我有信心漏洞在我的工作流程中。有人能让我朝正确的方向旋转吗?
答案1
国旗--no-csv-summary
是0.9版本添加,从 2015 年 3 月开始。您的版本是 0.6。这当前版本截至 2016 年 8 月为 1.0.2。
您可能需要添加官方 GoAccess Debian 存储库:
$ echo "deb http://deb.goaccess.io/ $(lsb_release -cs) main" | sudo tee -a /etc/apt/sources.list.d/goaccess.list
$ wget -O - https://deb.goaccess.io/gnugpg.key | sudo apt-key add -
$ sudo apt-get update
$ sudo apt-get install goaccess
或者从源代码构建,您可以找到相关指南这里。