def get_404(log): ''' Find the set of all requests with status 404 in the given `log` sequence >>> get_404('access-log') [] ''' l = [] for line in apachelog.lines_from_dir(log, 'www'): #print line for i in apachelog.apache_log(line): a = i['status'] b = i['request'] if a == '404': #print b if b not in l: l.append(b) return l
def get_largest(log): ''' Find the largest data transfer in the given `log` sequence >>> get_largest('access-log') (4919642, '/dynamic/ffcache.zip') ''' size = 0 f = 0 for line in apachelog.lines_from_dir(log, 'www'): for i in apachelog.apache_log(line): try: a = int(i["bytes"]) b = i["request"] except: continue if a > size: size = a f = b return size, f
def main(): '''Main function''' lines = apachelog.lines_from_dir('access-log*', 'www') log = apachelog.apache_log(lines) for r in sorted(get_404(log)): print r
def main(): '''Main function''' lines = apachelog.lines_from_dir('access-log*', 'www') log = apachelog.apache_log(lines) print 'Total: %d' % get_downloads_count(log, '/ply/ply-2.3.tar.gz')
def main(): '''Main function''' lines = apachelog.lines_from_dir('access-log*', 'www') log = apachelog.apache_log(lines) print '%d %s' % get_largest(log)