def testCombinedExample(self):
     combined_log_entry = '127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700]' \
                          ' "GET /apache_pb.gif HTTP/1.0" 200' \
                          ' 2326 "http://www.example.com/start.html" ' \
                          '"Mozilla/4.08 [en] (Win98; I ;Nav)"'
     self.assertEqual(apache_log_parser_split.dictify_logline(combined_log_entry),
                      {'remote_host': '127.0.0.1', 'status_code': '200', 'bytes_sent': '2326'})
 def testCombinedExample(self):
     # test the combined example from apache.org
     combined_log_entry = '127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] '\
         '"GET /apache_pb.gif HTTP/1.0" 200 2326 "http://www.example.com/start.html" '\
         '"Mozilla/4.08 [en] (Win98; I ;Nav)"'
     self.assertEqual(apache_log_parser_split.dictify_logline(combined_log_entry),
                      {'remote_host': '127.0.0.1', 'status': '200', 'bytes_sent': '2326'})
Exemplo n.º 3
0
 def testMalformed(self):
     common_log_entry = 'jacksonproject.cnc.bc.ca - - [09/Mar/2004:14:50:23 -0800] "GET /mailman/listinfo HTTP/1.1" 200 6893'
     self.assertEqual(
         apache_log_parser_split.dictify_logline(common_log_entry), {
             'remote_host': 'jacksonproject.cnc.bc.ca',
             'status': '200',
             'bytes_sent': '6893'
         })
Exemplo n.º 4
0
 def testCombinedExample(self):
     combined_log_entry = '127.0.0.1 - - [09/Mar/2004:13:14:53 -0800] "GET / HTTP/1.1" 200 2326'
     self.assertEquals(
         apache_log_parser_split.dictify_logline(combined_log_entry), {
             'remote_host': '127.0.0.1',
             'status': '200',
             'bytes_sent': '2326'
         })
Exemplo n.º 5
0
 def testMalformed(self):
     # test for extra whitespace between fields
     common_log_entry = '127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] '\
         '"GET /some/url/with white space.html HTTP/1.0" 200 2326'
     self.assertEqual(
         apache_log_parser_split.dictify_logline(common_log_entry), {
             'remote_host': '127.0.0.1',
             'status': '200',
             'bytes_sent': '2326'
         })
Exemplo n.º 6
0
 def testExtraWhitespace(self):
     # test the extra whitespace between fields
     common_log_entry = ' 127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] '\
         '"GET /apache_pb.gif HTTP/1.0" 200 2326'
     self.assertEqual(
         apache_log_parser_split.dictify_logline(common_log_entry), {
             'remote_host': '127.0.0.1',
             'status': '200',
             'bytes_sent': '2326'
         })
Exemplo n.º 7
0
 def testCommonExample(self):
     # test the common example from apache.org
     common_log_entry = '127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] '\
         '"GET /apache_pb.gif HTTP/1.0" 200 2326'
     self.assertEqual(
         apache_log_parser_split.dictify_logline(common_log_entry), {
             'remote_host': '127.0.0.1',
             'status': '200',
             'bytes_sent': '2326'
         })
Exemplo n.º 8
0
 def testCombinedExample(self):
     # test the combined example from apache.org
     combined_log_entry = '127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700' \
     '"GET /apache_pb.gif HTTP/1.0" 200 2326' \
     '"http://www.example.com/start.html" "Mozilla/4.08"'
     self.assertEqual(
         apache_log_parser_split.dictify_logline(combined_log_entry), {
             'remote_host': '127.0.0.1',
             'status': '200',
             'bytes_sent': '2326'
         })
 def testMalformed(self):
     # test for extra whitespace between fields
     common_log_entry = '127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] '\
         '"GET /some/url/with white space.html HTTP/1.0" 200 2326'
     self.assertEqual(apache_log_parser_split.dictify_logline(common_log_entry),
                      {'remote_host': '127.0.0.1', 'status': '200', 'bytes_sent': '2326'})
 def testExtraWhitespace(self):
     # test for extra whitespace between fields
     '"GET /apache_pb.gif HTTP/1.0" 200 2326'
     self.assertEqual(apache_log_parser_split.dictify_logline(common_log_entry),
                      {'remote_host': '127.0.0.1', 'status': '200', 'bytes_sent': '2326'})
 def testCommonExample(self):
     # test the common example from apache.org
     common_log_entry = '127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] '\
         '"GET /apache_pb.gif HTTP/1.0" 200 2326'
     self.assertEqual(apache_log_parser_split.dictify_logline(common_log_entry),
                      {'remote_host': '127.0.0.1', 'status': '200', 'bytes_sent': '2326'})
Exemplo n.º 12
0
#!/usr/bin/env python
import shelve
import apache_log_parser_split
logfile = open('ssl_access_log', 'r')
shelve_file = shelve.open('access.s')
for line in logfile:
	d_line = apache_log_parser_split.dictify_logline(line)
	shelve_file[d_line['remote_host']] = \
		shelve_file.setdefault(d_line['remote_host'], 0) + \
		int(d_line['bytes_sent'])
logfile.close()
shelve_file.close()

 def testMalformed(self):
     combined_log_entry = '127.0.0.1     -    frank [10/Oct/2000:13:55:36 -0700]' \
                          ' "GET     /apache_pb.gif/with white space.html HTTP/1.0" 200 2326'
     self.assertEqual(apache_log_parser_split.dictify_logline(combined_log_entry),
                      {'remote_host': '127.0.0.1', 'status_code': '200', 'bytes_sent': '2326'})
Exemplo n.º 14
0
	def testMalformed(self):
		common_log_entry = '127.0.0.1    -    - [24/Apr/2012:21:44:02 +0800] "GET /a/a b HTTP/1.1" 200 484 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11"'
		self.assertEqual(apache_log_parser_split.dictify_logline(common_log_entry),
				{'remote_host': '127.0.0.1', 'status': '200', 'bytes_sent': '484'})
Exemplo n.º 15
0
 def testExtraWhitespace(self):
     # test the extra whitespace between fields
     common_log_entry = ' 127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] '\
         '"GET /apache_pb.gif HTTP/1.0" 200 2326'
     self.assertEqual(apache_log_parser_split.dictify_logline(common_log_entry), {'remote_host': '127.0.0.1', 'status': '200', 'bytes_sent': '2326'})