码迷,mamicode.com
首页 > 其他好文 > 详细

统计大文件日志访问量

时间:2017-03-29 21:33:15      阅读:282      评论:0      收藏:0      [点我收藏+]

标签:日志访问量统计

日志格式:

#Version:1.0

#Fields:date time time-taken x-c_username bytes c-ip s-ip sc-status cs-method cs-uri-stem cs-uri x-c_sessionid

#Software:WebLogic

#Start-Date:2017-03-2700:01:13

2017-03-2700:01:130.043-3210.33.215.21810.12.216.147:30573200POST/appsvr/apv/blazeThreeSwitchForEsg/appsvr/apv/blazeThreeSwitchForEsg-

2017-03-2700:01:220.0050GROUPUSER29710.11.100.13610.12.216.147:30573302GET/index.jsp/‘B72BYXlSvxQJpBlTwPvVpZ2LtZvQNstnl0fnPpqn2QzSVwSgr224!1792055119!1490544082940‘

2017-03-2700:01:230.269GROUPUSER1046310.11.100.13610.12.216.147:30573200GET/cfs/index.screen/cfs/index.screen‘B72BYXlSvxQJpBlTwPvVpZ2LtZvQNstnl0fnPpqn2QzSVwSgr224!1792055119!1490544082940‘

2017-03-2700:01:230.07GROUPUSER1046310.11.100.13610.12.216.147:30573200GET/cfs/index.screen/cfs/index.screen‘B72BYXlSvxQJpBlTwPvVpZ2LtZvQNstnl0fnPpqn2QzSVwSgr224!1792055119!1490544082940‘

2017-03-2700:01:230.0020GROUPUSER1283010.11.100.13610.12.216.147:30573200GET/cfs/top.jsp/cfs/top.jsp‘B72BYXlSvxQJpBlTwPvVpZ2LtZvQNstnl0fnPpqn2QzSVwSgr224!1792055119!1490544082940‘

2017-03-2700:01:290.0-3010.12.216.210.12.216.147:30573200GET/f5monweb/f5check.jsp/f5monweb/f5check.jsp-

2017-03-2700:01:370.037DAIBANGXING4713310.53.209.8610.12.216.147:30573200POST/cfs/approval/querySystemHuEndAlert.do/cfs/approval/querySystemHuEndAlert.do‘tCppYJxJJ1fpfQkT4MGDTNMNZZXtPVT4FKTrxGjrYCSGnkLlg0p8!1792055119!1490334025837‘

2017-03-2700:02:330.011LUQIAN3073310.53.209.6510.12.216.147:30573200POST/cfs/approval/querySystemHuEndAlert.do/cfs/approval/querySystemHuEndAlert.do‘Q6Q1YXnJlqVdTww1LryvzR84cx4LTNxcKP2YDHHzDhfppKl1CCdh!1792055119!1490530004923‘

2017-03-2700:02:540.033DAIBANGXING4713310.53.209.8610.12.216.147:30573200POST/cfs/approval/querySystemHuEndAlert.do/cfs/approval/querySystemHuEndAlert.do‘tCppYJxJJ1fpfQkT4MGDTNMNZZXtPVT4FKTrxGjrYCSGnkLlg0p8!1792055119!1490334025837‘

2017-03-2700:03:180.0090DUXIAOLING2393310.53.208.15910.12.216.147:30573200POST/cfs/approval/querySystemHuEndAlert.do/cfs/approval/querySystemHuEndAlert.do‘5yLbYJSKlyBy1LTYf72XqQFQ2NWnQsFx2FRCWGnnRv6kHSljhP1v!1792055119!1490342474332‘

2017-03-2700:03:210.0010-3010.12.216.110.12.216.147:30573200GET/f5monweb/f5check.jsp/f5monweb/f5check.jsp-

2017-03-2700:03:410.637CHENSHU5243310.53.185.010.12.216.147:30573200POST/cfs/approval/querySystemHuEndAlert.do/cfs/approval/querySystemHuEndAlert.do‘yLB4YJ5PmmshQ5hS27QcPcjB317Kysh8xrR7yZVPmn0vbTbQdyvQ!1792055119!1490352559754‘

2017-03-2700:03:450.0010-3010.33.226.5cfs-apvWIIWebServer8130.instance.paic.com.cn:30573200GET/f5monweb/f5check.jsp/f5monweb/f5check.jsp-

2017-03-2700:03:590.54DAIBANGXING4713310.53.209.8610.12.216.147:30573200POST/cfs/approval/querySystemHuEndAlert.do/cfs/approval/querySystemHuEndAlert.do‘tCppYJxJJ1fpfQkT4MGDTNMNZZXtPVT4FKTrxGjrYCSGnkLlg0p8!1792055119!1490334025837‘

2017-03-2700:04:010.0-3010.12.216.110.12.216.147:30573200GET/f5monweb/f5check.jsp/f5monweb/f5check.jsp-

2017-03-2700:04:014.282-8610.33.213.9310.12.216.147:30573200POST/appsvr/apv/preApproved/appsvr/apv/preApproved-

2017-03-2700:04:010.024WANGZHENZHEN7073310.53.209.7110.12.216.147:30573200POST/cfs/approval/querySystemHuEndAlert.do/cfs/approval/querySystemHuEndAlert.do‘pQYmYXbh4RJWQwmcvvt5yDSpg45qNWxwLRQcnYWThvFhthyQt562!1792055119!1490492282307‘

2017-03-2700:09:580.012CHENSHU5243310.53.185.010.12.216.147:30573200POST/cfs/approval/querySystemHuEndAlert.do/cfs/approval/querySystemHuEndAlert.do‘yLB4YJ5PmmshQ5hS27QcPcjB317Kysh8xrR7yZVPmn0vbTbQdyvQ!1792055119!1490352559754‘

2017-03-2700:10:030.02WANGZHENZHEN7073310.53.209.7110.12.216.147:30573200POST/cfs/approval/querySystemHuEndAlert.do/cfs/approval/querySystemHuEndAlert.do‘pQYmYXbh4RJWQwmcvvt5yDSpg45qNWxwLRQcnYWThvFhthyQt562!1792055119!1490492282307‘

2017-03-2700:10:030.012DUXIAOLING2393310.53.208.15910.12.216.147:30573200POST/cfs/approval/querySystemHuEndAlert.do/cfs/approval/querySystemHuEndAlert.do‘5yLbYJSKlyBy1LTYf72XqQFQ2NWnQsFx2FRCWGnnRv6kHSljhP1v!1792055119!1490342474332‘

2017-03-2700:10:090.0-3010.12.216.210.12.216.147:30573200GET/f5monweb/f5check.jsp/f5monweb/f5check.jsp-

2017-03-2700:10:110.014LUQIAN3073310.53.209.6510.12.216.147:30573200POST/cfs/approval/querySystemHuEndAlert.do/cfs/approval/querySystemHuEndAlert.do‘Q6Q1YXnJlqVdTww1LryvzR84cx4LTNxcKP2YDHHzDhfppKl1CCdh!1792055119!1490530004923‘


import sys,linecache,time
#filename=sys.argv[1]
dateTime=raw_input("Pls enter the date (YYYY-mm-dd):")
#dateTime="2017-03-27"
#filename="D:\Users\WANWEI496\Downloads\cfs-apvWIIWebServer8130-20170327\cfs-apvWIIWebServer8130-20170327\cfs-apvWIIWebServer8130.acc00001"
filename=raw_input("And ur filename:")
lineNum=len(linecache.getlines(filename))
#print
#print "Total: ",lineNum
time.sleep(3)
s=set()
num=0
while True:
	if num < lineNum:
		cacheBig=linecache.getlines(filename)[num]	
		if cacheBig.startswith(dateTime):
		 	username=cacheBig.split()[3]
		 	s.add(username)
		 	#print num
		 	num+=1
		 	continue
		else:
			num+=1
		 	continue
	else:
		break
#print s
linecache.clearcache()
s.remove(‘-‘)
print
print "User account: ",len(s)


本文出自 “菜鸟也能飞” 博客,请务必保留此出处http://williamwan.blog.51cto.com/10818837/1911502

统计大文件日志访问量

标签:日志访问量统计

原文地址:http://williamwan.blog.51cto.com/10818837/1911502

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!