原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://baiying.blog.51cto.com/1068039/1565880
安装GoAccess
控制台使用GoAccess
-f <input-file> : 需要解析的日志文件
-a --agent-list : 在host模块是不是能点击IP出现这个IP的user-agentlist,就是出现如图的功能
-c --conf-dialog: 是否显示log和format配置对话窗口。
127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326主机 用户身份 作者 [日期] "请求方法 请求路径 请求协议" 状态码 字节数
125.125.125.125 - dsmith [10/Oct/1999:21:15:05 +0500] "GET /index.html HTTP/1.0" 200 1043 "http://www.ibm.com/" "Mozilla/4.05 [en] (WinNT; I)" "USERID=CustomerA;IMPID=01234"主机 用户身份 作者 [日期] "请求方法 请求路径 请求协议" 状态码 字节数 referrer 客户端代理 cookie
#Software: Microsoft Internet Information Server 4.0#Version: 1.0#Date: 1998-11-19 22:48:39#Fields: date time c-ip cs-username s-ip cs-method cs-uri-stem cs-uri-query sc-status sc-bytes cs-bytes time-taken cs-version cs(User-Agent) cs(Cookie) cs(Referrer)1998-11-19 22:48:39 206.175.82.5 - 208.201.133.173 GET /global/images/navlineboards.gif - 200 540 324 157 HTTP/1.0 Mozilla/4.0+(compatible;+MSIE+4.01;+Windows+95) USERID=CustomerA;+IMPID=01234 http://yourturn.rollingstone.com/webx?98@@webx1.html
-d --with-output-resolver 在HTML输出或者json输出中开启IP 解析
-e --exclude-ip=<ip address>
-h --help 帮助文档
-H --http-protocol 显示的时候是否带上HTTP协议信息
-m --with-mouse 控制面板开启支持鼠标点击,带上了m之后,双击鼠标就相当于回车的操作
-M --http-method 是否带上HTTP方法信息
-o --output-format=csv|json 输出为csv或者json形式
-p --conf-file=<filename>
-q --no-query-string
-r --no-term-resolver
--no-color
--real-os
下面说说的是控制台的键盘操作:
使用GoAccess生成文件
goaccess -d -f web.log -a -p /home/yejianfeng/.goaccessrc > test.html
goaccess -q -f web.log -a -p /home/yejianfeng/.goaccessrc -o json >test.json
goaccess -q -f web.log -a -p /home/yejianfeng/.goaccessrc -o csv>test.csv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#!/usr/bin/python #coding:utf-8 import smtplib import sys from email.Header import Header from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart from email.mime.image import MIMEImage def sendMail(sender,receiver,subject,attfile): smtpserver = 'smtp.126.com' username = 'admin123' password = '111111' msg = MIMEMultipart( 'alternative' ) msg[ 'Subject' ] = Header(subject, 'utf-8' ) f = open (attfile) html = ''.join(f.readlines()) f.close() part2 = MIMEText(html, 'html' , 'utf-8' ) msg.attach(part2) att = MIMEText( open (attfile, 'rb' ).read(), 'base64' , 'utf-8' ) att[ "Content-Type" ] = 'application/octet-stream' att[ "Content-Disposition" ] = 'attatchment;filename="report.html"' msg.attach(att) smtp = smtplib.SMTP() smtp.connect( 'smtp.126.com' ) smtp.login(username,password) smtp.sendmail(sender,receiver,msg.as_string()) smtp.quit() if __name__ = = '__main__' : sender = 'admin123@126.com' receiver = [ 'user01@126.com' , 'user02@126.com' ] subject = 'xxx日志分析报告' sendMail(sender,receiver,subject,sys.argv[ 1 ]) |
全站熱搜
留言列表