示例#1
0
def injobs():
	flag = 'ip'
	dbc = mongoclient('localhost',27017,'nginx111')
	i = logUtimes(dbc,-10)
	m = analysisM.getLogItems(i)[1]
	ipL = analysisM.countIP_URL(m,60,-10,flag)
	dbB = mongoclient('localhost',27017,'badip')
	badip2mongo(dbB,'iplist',ipL)
示例#2
0
def main():
	argS = argP().parse_args()
	if len(sys.argv) <= 1:
		argP().print_help()
	
	else:
		 
		if argS.ipurl:
			flag = 'ipurl'
			dbc = mongoclient(argS.dbhost,27017,argS.dbname)
			i = logUtimes(dbc,argS.times)
			m = analysisM.getLogItems(i,u'method',u'referer',u'code',u'size',u'agent')[1]
			analysisM.countIP_URL(m,argS.counts,argS.times,flag)
		elif argS.codemethod:
			dbc = mongoclient(argS.dbhost,27017,argS.dbname)
			i = logUtimes(dbc,argS.times)
			m = analysisM.getLogItems(i,u'method',u'referer',u'code',u'size',u'agent')[1]
			analysisM.c_m_Ocurrences(m)
		elif argS.searchU:
			flag = 'url'
			dbc = mongoclient(argS.dbhost,27017,argS.dbname)
			i = logUtimes(dbc,argS.times)
			m = analysisM.getLogItems(i,u'method',u'referer',u'code',u'size',u'agent')[1]
			analysisM.searchUrlorRefer(m,argS.keyword,argS.times,argS.counts,flag)
		elif argS.searchR:
			flag = 'referer'
			dbc = mongoclient(argS.dbhost,27017,argS.dbname)
			i = logUtimes(dbc,argS.times)
			m = analysisM.getLogItems(i,u'method',u'referer',u'code',u'size',u'agent')[1]
			analysisM.searchUrlorRefer(m,argS.keyword,argS.times,argS.counts,flag)
		elif argS.badip:
			flag = 'ip'
			dbc = mongoclient(argS.dbhost,27017,argS.dbname)
			i = logUtimes(dbc,argS.times)
			m = analysisM.getLogItems(i,u'method',u'referer',u'code',u'size',u'agent')[1]
			ipL = analysisM.countIP_URL(m,argS.counts,argS.times,flag)
			dbB = mongoclient('192.168.10.29',27017,'badip')
			badip2mongo(dbB,'iplist',ipL)
			for j in dbB.iplist.find():
				print j
			
		else:
			argP().print_help()